Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 465f1c2

Browse files
committed
fix(memory): Add protection against excessive on prop patching
This caused memory leaks in Jest JSDOM environment
1 parent 0a2f6ff commit 465f1c2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/common/utils.ts

+7
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ export function patchProperty(obj: any, prop: string, prototype?: any) {
158158
return;
159159
}
160160

161+
const onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched');
162+
if (obj[onPropPatchedSymbol]) {
163+
// return;
164+
}
165+
161166
// A property descriptor cannot have getter/setter and be writable
162167
// deleting the writable and value properties avoids this error:
163168
//
@@ -240,6 +245,8 @@ export function patchProperty(obj: any, prop: string, prototype?: any) {
240245
};
241246

242247
ObjectDefineProperty(obj, prop, desc);
248+
249+
obj[onPropPatchedSymbol] = true;
243250
}
244251

245252
export function patchOnProperties(obj: any, properties: string[]|null, prototype?: any) {

0 commit comments

Comments
 (0)