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

[release-3.0] [main->cherrypick] [BUG] Excessive memory usage for SPA where unload hooks keep accumulating #2311 (#2312) #2313

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions AISKU/Tests/Unit/src/AISKUSize.Tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { Snippet } from "../../../src/Snippet";
import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-common";

export class AISKUSizeCheck extends AITestClass {
private readonly MAX_RAW_SIZE = 135;
private readonly MAX_BUNDLE_SIZE = 135;
private readonly MAX_RAW_DEFLATE_SIZE = 54;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 54;
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";
// Automatically updated by version scripts
private readonly currentVer = "3.0.9";
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() {
// 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));
});
}
}
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();
}
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,8 +1,10 @@
import { AnalyticsPluginTests } from './AnalyticsPlugin.tests';
import { TelemetryItemCreatorTests } from './TelemetryItemCreator.tests';
import { AnalyticsExtensionSizeCheck } from "./AnalyticsExtensionSize.tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new AnalyticsPluginTests().registerTests();
new TelemetryItemCreatorTests().registerTests();
new AnalyticsExtensionSizeCheck().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 { CfgSyncHelperTests } from "./cfgsynchelper.tests";
import {CfgSyncPluginTests} from "./cfgsyncplugin.tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new CfgSyncPluginTests().registerTests();
new CfgSyncHelperTests().registerTests();
}
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,5 +1,7 @@
import { ClickEventTest } from './ClickEventTest';
import { GlobalTestHooks } from './GlobalTestHooks.Test';

export function runTests() {
new GlobalTestHooks().registerTests();
new ClickEventTest().registerTests();
}
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,6 +1,8 @@
import { AjaxTests, AjaxPerfTrackTests, AjaxFrozenTests } from "./ajax.tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new AjaxTests().registerTests();
new AjaxPerfTrackTests().registerTests();
new AjaxFrozenTests().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,5 +1,7 @@
import { MarkMeasureTests } from './MarkMeasureTests';
import { GlobalTestHooks } from './GlobalTestHooks.Test';

export function runTests() {
new GlobalTestHooks().registerTests();
new MarkMeasureTests().registerTests();
}
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 @@ -3,8 +3,10 @@ import { PropertiesTests } from "./properties.tests";
import { SessionManagerTests } from "./SessionManager.Tests";
import { PropertiesExtensionSizeCheck } from "./propertiesSize.tests";
import { TelemetryContextTests } from "./TelemetryContext.Tests";
import { GlobalTestHooks } from './GlobalTestHooks.Test';

export function runTests() {
new GlobalTestHooks().registerTests();
new PropertiesTests().registerTests();
new SessionManagerTests(false).registerTests();
new SessionManagerTests(true).registerTests();
Expand Down
5 changes: 4 additions & 1 deletion shared/1ds-core-js/src/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export {
IConfigCheckFn, IConfigDefaultCheck, IConfigDefaults, IConfigSetFn, IDynamicConfigHandler, IDynamicPropertyHandler,
IWatchDetails, IWatcherHandler, WatcherFunction,
createDynamicConfig, onConfigChange, getDynamicConfigHandler, blockDynamicConversion, forceDynamicConversion,
IPayloadData, IXHROverride, OnCompleteCallback, SendPOSTFunction
IPayloadData, IXHROverride, OnCompleteCallback, SendPOSTFunction,

// Test Hooks
_testHookMaxUnloadHooksCb
} from "@microsoft/applicationinsights-core-js";

export {
Expand Down
4 changes: 2 additions & 2 deletions shared/1ds-core-js/test/Unit/src/FileSizeCheckTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { AITestClass } from "@microsoft/ai-test-framework";
import * as pako from 'pako';

export class FileSizeCheckTest extends AITestClass {
private readonly MAX_BUNDLE_SIZE = 60;
private readonly MAX_DEFLATE_SIZE = 26;
private readonly MAX_BUNDLE_SIZE = 66;
private readonly MAX_DEFLATE_SIZE = 28;
private readonly bundleFilePath = "../bundle/es5/ms.core.min.js";

public testInitialize() {
Expand Down
13 changes: 13 additions & 0 deletions shared/1ds-core-js/test/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 shared/1ds-core-js/test/Unit/src/core.unittests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { DynamicProtoTests } from './DynamicProtoTests';
import { UtilsTest } from './UtilsTest';
import { ValueSanitizerTests } from './ValueSanitizerTests';
import {FileSizeCheckTest} from './FileSizeCheckTest'
import { GlobalTestHooks } from './GlobalTestHooks.Test';



export function registerTests() {
new GlobalTestHooks().registerTests();
new CoreTest('CoreTest').registerTests();
new ESPromiseTests('ESPromiseTests').registerTests();
new ESPromiseSchedulerTests('ESPromiseSchedulerTests').registerTests();
Expand Down
13 changes: 13 additions & 0 deletions shared/AppInsightsCommon/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 { ConnectionStringParserTests } from "./ConnectionStringParser.tests";
import { SeverityLevelTests } from "./SeverityLevel.tests";
import { RequestHeadersTests } from "./RequestHeaders.tests";
import { ThrottleMgrTest } from "./ThrottleMgr.tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new ThrottleMgrTest().registerTests();
new ApplicationInsightsTests().registerTests();
new ExceptionTests().registerTests();
Expand Down
Loading
Loading