Title: zone.js promises returning Unhandled Promise Rejection error even with catch blocks · Issue #31680 · angular/angular · GitHub
Open Graph Title: zone.js promises returning Unhandled Promise Rejection error even with catch blocks · Issue #31680 · angular/angular
X Title: zone.js promises returning Unhandled Promise Rejection error even with catch blocks · Issue #31680 · angular/angular
Description: I am working on an angular environment with zone.js so all the native es6 promises have been over-written by zone-aware promises. I have 2 functions called save() and onSaveCb() save() calls a function called validate() which gets the er...
Open Graph Description: I am working on an angular environment with zone.js so all the native es6 promises have been over-written by zone-aware promises. I have 2 functions called save() and onSaveCb() save() calls a func...
X Description: I am working on an angular environment with zone.js so all the native es6 promises have been over-written by zone-aware promises. I have 2 functions called save() and onSaveCb() save() calls a func...
Opengraph URL: https://github.com/angular/angular/issues/31680
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"zone.js promises returning Unhandled Promise Rejection error even with catch blocks","articleBody":"I am working on an angular environment with zone.js so all the native es6 promises have been over-written by zone-aware promises. I have 2 functions called save() and onSaveCb()\r\n\r\nsave() calls a function called validate() which gets the error-codes of any of the saved objects already present in the file so it is done in sync.\r\n\r\nif hasError() returns true we return Promise.reject() from save() otherwise we send a save request to the backend.\r\n\r\nNow, onSaveCb() function is an async/await function which has a try-catch block around save().\r\n\r\nProblem:\r\n\r\nWhen Promise is rejected from save() function, I see console log error:\r\n\r\nzone.js:682 Unhandled Promise rejection: ; Zone: ; Task: onClick Event ; Value: Error:\r\n\r\nI tried a bunch of things with wrapping the function save in a promise and then rejecting it, but i still see the same error\r\n```\r\nfunction save() {\r\n let errorCode = this.validate(); // This is a sync call\r\n if(errorCode !== 0) { return Promise.reject(errorCode);}\r\n return https(url).then(function() {return true});\r\n} \r\n\r\nfunction async onSaveCb() {\r\n try{\r\n let response = await this.save();\r\n alertUI(response);\r\n } catch (response) {\r\n alertUI(response);\r\n }\r\n}\r\n```\r\n\r\nI am not sure why I am getting this message when I have clearly written error handling in the catch block. Any help here would be helpful","author":{"url":"https://github.com/utsavkapoor","@type":"Person","name":"utsavkapoor"},"datePublished":"2019-05-22T20:36:24Z","url":"https://github.com/angular/angular/issues/31680"}
| 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:0e4bca3b-9461-2d2f-4c69-3092caaabe7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8CFC:14ECB:18CCB60:1F7CB56:6B014310 |
| html-safe-nonce | 714824de3561eb3683282a57d98ad8dd6de157b707a9d016bf05ea5148d74994 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0ZDOjE0RUNCOjE4Q0NCNjA6MUY3Q0I1Njo2QjAxNDMxMCIsInZpc2l0b3JfaWQiOiI0OTkwMTExNzQ0Njc3NDYyODAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 969407f934420c10e2c3da8f7b6747326187ee3a9e7d960aa45c5e65bb352d54 |
| hovercard-subject-tag | issue:470723997 |
| 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/31680/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6a15000c3b8b7f6fd726c39ad3a8884163c460d1a17a72645ccb4799295ecdfc/angular/angular/issues/31680 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6a15000c3b8b7f6fd726c39ad3a8884163c460d1a17a72645ccb4799295ecdfc/angular/angular/issues/31680 |
| og:image:alt | I am working on an angular environment with zone.js so all the native es6 promises have been over-written by zone-aware promises. I have 2 functions called save() and onSaveCb() save() calls a func... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | utsavkapoor |
| 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