Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Excessive memory usage for SPA where unload hooks keep accumulating #2311 #2312

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AISKU/Tests/Unit/src/AISKUSize.Tests.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using a "hack" of our current test infrastructure to "set" some global configuration that will affect "ALL" tests that follow the initialization. (which is why this was added as the "first" item of every tests bundle.

Of note, is that IF any test also changes / sets / calls the test hook it will "replace" and invalidate this setting (as this is currently a single value, not a list of callbacks)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They also needed to be created / added here as the "common" test infrastructure does not have access to the main "Application Insights" code to be able to add code specific "hooks"

// 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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));
});
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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));
});
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { TeeChannelCoreTests } from "./TeeChannelCore.Tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

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