angular-cn/packages/zone.js/lib
JiaLiPassion 0652b29f62 fix(zone.js): setTimeout patch should clean tasksByHandleId cache. (#40586)
Close #40387

Currently zone.js patches `setTimeout` and keeps a `tasksByHandleId` map to keep `timerId` <-> `ZoneTask`
relationship. This is needed so that when `clearTimeout(timerId)` is called, zone.js can find the associated
`ZoneTask`. Now zone.js set the `tasksByHandleId` map in the `scheduleTask` function, but if the `setTimeout`
is running in the `FakeAsyncZoneSpec` or any other `ZoneSpec` with `onScheduleTask` hooks. The `scheduleTask`
in `timer` patch may not be invoked.

For example:

```
fakeAsync(() => {
  setTimeout(() => {});
  tick();
});
```

In this case, the `timerId` kept in the `tasksByHandleId` map is not cleared.
This is because the `FakeAsyncZoneSpec` in the `onScheduleTask` hook looks like this.

```
onScheduleTask(delegate, ..., task) {
  fakeAsyncScheduler.setTimeout(task);
  return task;
}
```

Because `FakeAsyncZoneSpec` handles the task itself and it doesn't call `parentDelegate.onScheduleTask`,
therefore the default `scheduleTask` in the `timer` patch is not invoked.

In this commit, the cleanup logic is moved from `scheduleTask` to `setTimeout` patch entry to
avoid the memory leak.

PR Close #40586
2021-02-09 10:43:05 -08:00
..
browser feat(zone.js): monkey patches queueMicrotask() (#38904) 2020-11-05 11:23:33 -08:00
closure fix(zone.js): fix typo in zone_externs (#40348) 2021-01-08 09:47:46 -08:00
common fix(zone.js): setTimeout patch should clean tasksByHandleId cache. (#40586) 2021-02-09 10:43:05 -08:00
extra fix(zone.js): remove unused Promise overwritten setter logic (#36851) 2020-06-11 18:56:19 -07:00
jasmine refactor(zone.js): rename several internal apis in fake async zone spec (#39127) 2020-10-13 15:56:22 -07:00
jest refactor(zone.js): rename several internal apis in fake async zone spec (#39127) 2020-10-13 15:56:22 -07:00
mix build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
mocha build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
node fix(zone.js): patch nodejs EventEmtter.prototype.off (#37863) 2020-07-24 15:45:00 -07:00
rxjs fix(zone.js): zone patch rxjs should return null _unsubscribe correctly. (#37091) 2020-07-27 12:10:27 -07:00
testing refactor(core): remove unused fakeAsyncFallback and asyncFallback (#37879) 2020-11-20 08:34:59 -08:00
zone-spec refactor(core): remove unused fakeAsyncFallback and asyncFallback (#37879) 2020-11-20 08:34:59 -08:00
BUILD.bazel build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#39182) 2020-10-08 11:54:59 -07:00
zone-global.d.ts fix(zone.js): remove global declaration (#37861) 2020-10-23 15:19:49 -07:00
zone.api.extensions.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
zone.configurations.api.ts feat(zone.js): monkey patches queueMicrotask() (#38904) 2020-11-05 11:23:33 -08:00
zone.ts refactor(core): remove unused fakeAsyncFallback and asyncFallback (#37879) 2020-11-20 08:34:59 -08:00