Title: Promise rejection with finally, does not throw unhandled rejection · Issue #47562 · angular/angular · GitHub
Open Graph Title: Promise rejection with finally, does not throw unhandled rejection · Issue #47562 · angular/angular
X Title: Promise rejection with finally, does not throw unhandled rejection · Issue #47562 · angular/angular
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 https://git...
Open Graph 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 min...
X 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 min...
Opengraph URL: https://github.com/angular/angular/issues/47562
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Promise rejection with finally, does not throw unhandled rejection","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\nzone.js\r\n\r\n### Is this a regression?\r\n\r\nNo\r\n\r\n### Description\r\n\r\nPromise rejection with finally, does not throw unhandled rejection\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\nhttps://github.com/sviat9440/zone-js-bug-reproduction.git\r\n\r\n### Please provide the exception or error you saw\r\n\r\n## Expected\r\n\r\n1. If the promise is rejected, the final callback should be executed\r\n2. After that, it should throw the UnhandledPromiseRejection error\r\n\r\n## Actual without zone.js\r\n\r\n```true\r\nPromise.reject(new Error('test error')).finally(() => console.log('finally'));\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nfinally\r\nfile:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/work-as-expected.js:1\r\nPromise.reject(new Error('test error')).finally(() => console.log('finally'));\r\n ^\r\n\r\nError: test error\r\n at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/work-as-expected.js:1:16\r\n at ModuleJob.run (node:internal/modules/esm/module_job:198:25)\r\n at async Promise.all (index 0)\r\n at async ESMLoader.import (node:internal/modules/esm/loader:385:24)\r\n at async loadESM (node:internal/process/esm_loader:88:5)\r\n at async handleMainPromise (node:internal/modules/run_main:61:12)\r\n\r\nProcess finished with exit code 1\r\n```\r\n\r\nBrowser output:\r\n\r\n\r\n\r\nWork as expected\r\n\r\n## Actual with zone.js\r\n\r\n### Case 1\r\n\r\n```\r\nimport 'zone.js';\r\n\r\nPromise.reject(new Error('test error')).finally(() => console.log('finally'));\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nfinally\r\n\r\nProcess finished with exit code 0\r\n```\r\n\r\nBrowser output:\r\n\r\n\r\n### Case 2\r\n\r\n```\r\nimport 'zone.js';\r\n\r\nPromise.reject(new Error('test error'));\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nUnhandled Promise rejection: test error ; Zone: \u003croot> ; Task: null ; Value: Error: test error\r\n at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/not-work-as-expected.js:3:16\r\n at ModuleJob.run (node:internal/modules/esm/module_job:198:25)\r\n at async Promise.all (index 0)\r\n at async ESMLoader.import (node:internal/modules/esm/loader:385:24)\r\n at async loadESM (node:internal/process/esm_loader:88:5)\r\n at async handleMainPromise (node:internal/modules/run_main:61:12) Error: test error\r\n at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/not-work-as-expected.js:3:16\r\n at ModuleJob.run (node:internal/modules/esm/module_job:198:25)\r\n at async Promise.all (index 0)\r\n at async ESMLoader.import (node:internal/modules/esm/loader:385:24)\r\n at async loadESM (node:internal/process/esm_loader:88:5)\r\n at async handleMainPromise (node:internal/modules/run_main:61:12)\r\n\r\nProcess finished with exit code 0\r\n```\r\n\r\nBrowser output:\r\n\r\n\r\n\r\nUnhandledPromiseRejection error is thrown only without finally callback, exit code was 0\r\n\r\n\r\n## Workaround\r\n\r\n```\r\nimport 'zone.js';\r\n\r\ntry {\r\n await Promise.reject(new Error('test error'));\r\n} finally {\r\n console.log('finally');\r\n}\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nUnhandled Promise rejection: test error ; Zone: \u003croot> ; Task: null ; Value: Error: test error\r\n at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/workaround.js:4:24\r\n at ModuleJob.run (node:internal/modules/esm/module_job:198:25)\r\n at async Promise.all (index 0)\r\n at async ESMLoader.import (node:internal/modules/esm/loader:385:24)\r\n at async loadESM (node:internal/process/esm_loader:88:5)\r\n at async handleMainPromise (node:internal/modules/run_main:61:12) Error: test error\r\n at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/workaround.js:4:24\r\n at ModuleJob.run (node:internal/modules/esm/module_job:198:25)\r\n at async Promise.all (index 0)\r\n at async ESMLoader.import (node:internal/modules/esm/loader:385:24)\r\n at async loadESM (node:internal/process/esm_loader:88:5)\r\n at async handleMainPromise (node:internal/modules/run_main:61:12)\r\nfinally\r\nnode:internal/process/esm_loader:94\r\n internalBinding('errors').triggerUncaughtException(\r\n ^\r\n\r\nError: test error\r\n at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/workaround.js:4:24\r\n at ModuleJob.run (node:internal/modules/esm/module_job:198:25)\r\n at async Promise.all (index 0)\r\n at async ESMLoader.import (node:internal/modules/esm/loader:385:24)\r\n at async loadESM (node:internal/process/esm_loader:88:5)\r\n at async handleMainPromise (node:internal/modules/run_main:61:12)\r\n\r\nProcess finished with exit code 1\r\n```\r\n\r\nBrowser output: \r\n\r\n\r\nError reported twice: UnhandledPromiseRejection and Error('test error'). Expected no UnhandledPromiseRejection from Zone\r\n\r\n## Side effect\r\n\r\nUnhandled errors in promises with finally callback is missing. Console is empty. Logging systems also do not see such errors.\r\n\r\nIn browser the same situation.\r\n\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```true\r\n\"zone.js\": \"^0.11.8\"\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\n_No response_","author":{"url":"https://github.com/sviat9440","@type":"Person","name":"sviat9440"},"datePublished":"2022-09-27T19:09:10Z","url":"https://github.com/angular/angular/issues/47562"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ff834838-1d8e-924d-794c-69f9abffe6b1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 957A:2270F4:26C0458:3376160:6B01A5F2 |
| html-safe-nonce | 9da50634b5af8ff4b94dce04585c234771dd849bd618d0e4a2f097471197a12e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTdBOjIyNzBGNDoyNkMwNDU4OjMzNzYxNjA6NkIwMUE1RjIiLCJ2aXNpdG9yX2lkIjoiNjMzOTg4MzA4OTQ5NzUzMTg5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 28bb760706bb5565746de6a36165100a6d9998e9406b316f2ab1d54119727c8c |
| hovercard-subject-tag | issue:1388236323 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/47562/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a56657ee45b6f3aa31815e0d756563011bb39a84695d651fefb06a7b6f9106b0/angular/angular/issues/47562 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a56657ee45b6f3aa31815e0d756563011bb39a84695d651fefb06a7b6f9106b0/angular/angular/issues/47562 |
| og:image:alt | 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 min... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sviat9440 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width