Skip to content

Commit eb99d8e

Browse files
authored
fix: Avoid handling promise rejections twice in stability helper (#3657)
`PendingTasks.run` reports rejections of the promise to the `ErrorHandler`. This function already returns a promise that is meant to be handled in the developer's application. If there _is_ handling there, the rejection is handled both in the `PendingTasks.run` and in the developer callsite. This change updates the code to use `PendingTasks.add` instead, which has no built in error handling mechanisms. fixes angular/angular#61932
1 parent c1c6af9 commit eb99d8e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/zones.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ export const ɵzoneWrap = <T= unknown>(it: T, blockUntilFirst: boolean, logLevel
170170
// eslint-disable-next-line @typescript-eslint/no-misused-promises
171171
return run(
172172
() => {
173-
pendingTasks.run(() => ret);
173+
const removeTask = pendingTasks.add();
174174
return new Promise((resolve, reject) => {
175175
ret.then(
176176
(it) => runInInjectionContext(injector, () => run(() => resolve(it))),
177177
(reason) => runInInjectionContext(injector, () => run(() => reject(reason)))
178-
)
178+
).finally(removeTask);
179179
});
180180
});
181181
} else if (typeof ret === 'function' && taskDone) {

0 commit comments

Comments
 (0)