Repository navigation
Closed as duplicate
Closed as duplicate
Copy link
Labels
P4A relatively minor issue that is not relevant to core functionsA relatively minor issue that is not relevant to core functionsarea: zonesIssues related to zone.jsIssues related to zone.jsstate: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
zone.js
Is this a regression?
No
Description
Promise rejection with finally, does not throw unhandled rejection
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
Expected
- If the promise is rejected, the final callback should be executed
- After that, it should throw the UnhandledPromiseRejection error
Actual without zone.js
Promise.reject(new Error('test error')).finally(() => console.log('finally'));
Output:
finally
file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/work-as-expected.js:1
Promise.reject(new Error('test error')).finally(() => console.log('finally'));
^
Error: test error
at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/work-as-expected.js:1:16
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)
Process finished with exit code 1
Work as expected
Actual with zone.js
Case 1
import 'zone.js';
Promise.reject(new Error('test error')).finally(() => console.log('finally'));
Output:
finally
Process finished with exit code 0
Case 2
import 'zone.js';
Promise.reject(new Error('test error'));
Output:
Unhandled Promise rejection: test error ; Zone: <root> ; Task: null ; Value: Error: test error
at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/not-work-as-expected.js:3:16
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12) Error: test error
at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/not-work-as-expected.js:3:16
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)
Process finished with exit code 0
UnhandledPromiseRejection error is thrown only without finally callback, exit code was 0
Workaround
import 'zone.js';
try {
await Promise.reject(new Error('test error'));
} finally {
console.log('finally');
}
Output:
Unhandled Promise rejection: test error ; Zone: <root> ; Task: null ; Value: Error: test error
at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/workaround.js:4:24
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12) Error: test error
at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/workaround.js:4:24
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)
finally
node:internal/process/esm_loader:94
internalBinding('errors').triggerUncaughtException(
^
Error: test error
at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/workaround.js:4:24
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)
Process finished with exit code 1
Error reported twice: UnhandledPromiseRejection and Error('test error'). Expected no UnhandledPromiseRejection from Zone
Side effect
Unhandled errors in promises with finally callback is missing. Console is empty. Logging systems also do not see such errors.
In browser the same situation.
Please provide the environment you discovered this bug in (run ng version)
"zone.js": "^0.11.8"
Anything else?
No response
Metadata
Metadata
Assignees
Labels
P4A relatively minor issue that is not relevant to core functionsA relatively minor issue that is not relevant to core functionsarea: zonesIssues related to zone.jsIssues related to zone.jsstate: has PR




Activity
[-]Promise rejection with finnaly, does not throw unhandled rejection[/-][+]Promise rejection with finally, does not throw unhandled rejection[/+]AndrewKushnir commentedon Sep 28, 2022
Thanks for reporting the issue. It looks related to (should be fixed by?) the change in PR #46462.
sviat9440 commentedon Sep 28, 2022
The last activity there was on June 15. Are there any progress?
JiaLiPassion commentedon Mar 26, 2023
I created a PR to fix this one. #49589
angular-automatic-lock-bot commentedon Oct 3, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.