Skip to content

Commit 02fa901

Browse files
fix(selectivity): memory-leak when calculating testplane-deps
1 parent ded3cfc commit 02fa901

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/browser/cdp/selectivity/testplane-selectivity.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ export const getCollectedTestplaneDependencies = (): Set<string> | null => {
5555
export const runWithTestplaneDependenciesCollecting = <T>(fn: () => Promise<T>): Promise<T> => {
5656
enableCollectingTestplaneDependencies();
5757

58-
const store = { jsTestplaneDeps: new Set<string>() };
58+
const store: { jsTestplaneDeps?: Set<string> } = { jsTestplaneDeps: new Set() };
5959

60-
return testDependenciesStorage.run(store, fn);
60+
return testDependenciesStorage.run(store, fn).finally(() => {
61+
// After "fn" completion, "store" is reachable in CDP ping interval callback, so it never GC-removed
62+
// Thats why we do it manually. Removing "jsTestplaneDeps" is enough, and set remains unchanged, if used
63+
delete store.jsTestplaneDeps;
64+
});
6165
};
6266

6367
export const readTestFileWithTestplaneDependenciesCollecting = <T>(file: string, fn: () => Promise<T>): Promise<T> => {

0 commit comments

Comments
 (0)