Skip to content

Commit

Permalink
[BUG] Excessive memory usage for SPA where unload hooks keep accumula…
Browse files Browse the repository at this point in the history
…ting #2311 (#2312)

- Rework Asynchronous notification handling
  • Loading branch information
MSNev committed Mar 20, 2024
1 parent 2eaa2d5 commit 276c123
Show file tree
Hide file tree
Showing 41 changed files with 606 additions and 283 deletions.
4 changes: 2 additions & 2 deletions AISKU/Tests/Unit/src/AISKUSize.Tests.ts
Expand Up @@ -5,8 +5,8 @@ import { Snippet } from "../../../src/Snippet";
import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-common";

export class AISKUSizeCheck extends AITestClass {
private readonly MAX_RAW_SIZE = 139;
private readonly MAX_BUNDLE_SIZE = 139;
private readonly MAX_RAW_SIZE = 140;
private readonly MAX_BUNDLE_SIZE = 140;
private readonly MAX_RAW_DEFLATE_SIZE = 56;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 56;
private readonly rawFilePath = "../dist/es5/applicationinsights-web.min.js";
Expand Down
13 changes: 13 additions & 0 deletions AISKU/Tests/Unit/src/GlobalTestHooks.Test.ts
@@ -0,0 +1,13 @@
import { Assert } from "@microsoft/ai-test-framework";
import { _testHookMaxUnloadHooksCb } from "@microsoft/applicationinsights-core-js";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
2 changes: 2 additions & 0 deletions AISKU/Tests/Unit/src/aiskuunittests.ts
Expand Up @@ -2,6 +2,7 @@ import { AISKUSizeCheck } from "./AISKUSize.Tests";
import { ApplicationInsightsTests } from './applicationinsights.e2e.tests';
import { ApplicationInsightsFetchTests } from './applicationinsights.e2e.fetch.tests';
import { CdnPackagingChecks } from './CdnPackaging.tests';
import { GlobalTestHooks } from './GlobalTestHooks.Test';
import { SanitizerE2ETests } from './sanitizer.e2e.tests';
import { ValidateE2ETests } from './validate.e2e.tests';
import { SenderE2ETests } from './sender.e2e.tests';
Expand All @@ -10,6 +11,7 @@ import { CdnThrottle} from "./CdnThrottle.tests";
import { ThrottleSentMessage } from "./ThrottleSentMessage.tests";

export function runTests() {
new GlobalTestHooks().registerTests();
new AISKUSizeCheck().registerTests();
new ApplicationInsightsTests().registerTests();
new ApplicationInsightsFetchTests().registerTests();
Expand Down
13 changes: 13 additions & 0 deletions AISKULight/Tests/Unit/src/GlobalTestHooks.Test.ts
@@ -0,0 +1,13 @@
import { Assert } from "@microsoft/ai-test-framework";
import { _testHookMaxUnloadHooksCb } from "@microsoft/applicationinsights-core-js";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
2 changes: 2 additions & 0 deletions AISKULight/Tests/Unit/src/aiskuliteunittests.ts
@@ -1,8 +1,10 @@
import { AISKULightSizeCheck } from "./AISKULightSize.Tests";
import { ApplicationInsightsDynamicConfigTests } from "./dynamicconfig.tests";
import { ApplicationInsightsConfigTests } from "./config.tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new AISKULightSizeCheck().registerTests();
new ApplicationInsightsDynamicConfigTests().registerTests();
new ApplicationInsightsConfigTests().registerTests();
Expand Down
13 changes: 13 additions & 0 deletions channels/1ds-post-js/test/Unit/src/GlobalTestHooks.Test.ts
@@ -0,0 +1,13 @@
import { _testHookMaxUnloadHooksCb } from "@microsoft/1ds-core-js";
import { Assert } from "@microsoft/ai-test-framework";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
2 changes: 2 additions & 0 deletions channels/1ds-post-js/test/Unit/src/post.unittests.ts
Expand Up @@ -3,8 +3,10 @@ import { HttpManagerTest } from './HttpManagerTest';
import { KillSwitchTest } from './KillSwitchTest';
import { SerializerTest } from './SerializerTest';
import { FileSizeCheckTest } from "./FileSizeCheckTest"
import { GlobalTestHooks } from './GlobalTestHooks.Test';

export function registerTests() {
new GlobalTestHooks().registerTests();
new PostChannelTest("PostChannelTest").registerTests();
new HttpManagerTest("HttpManagerTest").registerTests();
new HttpManagerTest("HttpManagerTest", true).registerTests();
Expand Down
@@ -0,0 +1,13 @@
import { Assert } from "@microsoft/ai-test-framework";
import { _testHookMaxUnloadHooksCb } from "@microsoft/applicationinsights-core-js";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
@@ -1,7 +1,9 @@
import { SenderTests } from "./Sender.tests";
import { SampleTests } from "./Sample.tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new SenderTests().registerTests();
new SampleTests().registerTests();
}
13 changes: 13 additions & 0 deletions channels/offline-channel-js/Tests/Unit/src/GlobalTestHooks.Test.ts
@@ -0,0 +1,13 @@
import { Assert } from "@microsoft/ai-test-framework";
import { _testHookMaxUnloadHooksCb } from "@microsoft/applicationinsights-core-js";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
Expand Up @@ -5,8 +5,10 @@ import { OfflineInMemoryBatchTests } from "./inmemorybatch.tests";
import { OfflineBatchHandlerTests } from "./offlinebatchhandler.tests";
import { ChannelTests } from "./channel.tests";
import { Offlinetimer } from "./offlinetimer.tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new OfflineIndexedDBTests().registerTests();
new OfflineWebProviderTests().registerTests();
new OfflineDbProviderTests().registerTests();
Expand Down
13 changes: 13 additions & 0 deletions channels/tee-channel-js/Tests/Unit/src/GlobalTestHooks.Test.ts
@@ -0,0 +1,13 @@
import { Assert } from "@microsoft/ai-test-framework";
import { _testHookMaxUnloadHooksCb } from "@microsoft/applicationinsights-core-js";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
2 changes: 2 additions & 0 deletions channels/tee-channel-js/Tests/Unit/src/teechannel.tests.ts
@@ -1,5 +1,7 @@
import { TeeChannelCoreTests } from "./TeeChannelCore.Tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new TeeChannelCoreTests().registerTests();
}

0 comments on commit 276c123

Please sign in to comment.