Memory leak in tests with zone.js >= 0.9.0

🐞 bug report

Affected Package

The issue is caused by package:

zone.js: 0.9.0

Is this a regression?

Yes. The tests didn’t cause Chrome to crash.


When I’ve upgraded zone.js from 0.8.26 to 0.9.0 or higher, this problem appeared. I have 3000 unit/integration tests. We use heavily dynamic component creation. Our tests currently cannot be executed at once, because zone.js(the timers patch) keeps a reference to tasks created from setTimeout() in tasksByHandleId in the patch method. When I call clearTimeout() in ngOnDestroy() I can see that the task is not removed from tasksByHandleId because it’s status is notScheduled.

🔬 Minimal Reproduction

🌍 Your Environment

Angular Version:

Angular CLI: 11.0.6
Node: 14.3.0
OS: win32 x64

Angular: 11.0.7
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
@angular-devkit/architect       0.1100.6
@angular-devkit/build-angular   0.1100.6
@angular-devkit/core            11.0.6
@angular-devkit/schematics      11.0.6
@angular/cli                    11.0.6
@schematics/angular             11.0.6
@schematics/update              0.1100.6
rxjs                            6.6.3
typescript                      4.0.5
zone.js                         0.10.2

Anything else relevant?

1 possible answer(s) on “Memory leak in tests with zone.js >= 0.9.0