Title: [zonejs] XMLHttpRequest macrotask left hanging if `onload` throws · Issue #41520 · angular/angular · GitHub
Open Graph Title: [zonejs] XMLHttpRequest macrotask left hanging if `onload` throws · Issue #41520 · angular/angular
X Title: [zonejs] XMLHttpRequest macrotask left hanging if `onload` throws · Issue #41520 · angular/angular
Description: 🐞 bug report Affected Package The issue is caused by package @angular/zone.js. Is this a regression? AFAICT it has always been like this. Description ZoneJS invokes the XHR macrotask after all existing load handlers run, but if any of th...
Open Graph Description: 🐞 bug report Affected Package The issue is caused by package @angular/zone.js. Is this a regression? AFAICT it has always been like this. Description ZoneJS invokes the XHR macrotask after all exis...
X Description: 🐞 bug report Affected Package The issue is caused by package @angular/zone.js. Is this a regression? AFAICT it has always been like this. Description ZoneJS invokes the XHR macrotask after all exis...
Opengraph URL: https://github.com/angular/angular/issues/41520
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[zonejs] XMLHttpRequest macrotask left hanging if `onload` throws","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\nThe issue is caused by package @angular/zone.js.\r\n\r\n### Is this a regression?\r\nAFAICT it has always been like this.\r\n\r\n### Description\r\nZoneJS invokes the XHR macrotask after all existing `load` handlers run, but if any of them throw an unhandled exception, the task remains stuck in a `scheduled` state and none of the delegate hooks (e.g. `onInvokeTask()`) run. This creates problems for test environments and any instrumentation that relies on task counts.\r\n\r\n(It is somewhat similar to issue #38795.)\r\n\r\n\r\n## 🔬 Minimal Reproduction\r\n```javascript\r\nZone.root\r\n .fork({\r\n name: 'xhr',\r\n onHasTask(delegate, currentZone, zone, taskState) {\r\n console.log('hasMacrotask', taskState.macroTask);\r\n return delegate.hasTask(zone, taskState);\r\n }, \r\n })\r\n .run(() => {\r\n const xhr = new XMLHttpRequest();\r\n xhr.open('GET', 'https://cdnjs.cloudflare.com/ajax/libs/zone.js/0.11.4/zone.min.js');\r\n xhr.addEventListener('load', () => {\r\n throw new Error();\r\n });\r\n xhr.send();\r\n });\r\n```\r\n\r\nThis code ends by printing `hasMacrotask true` and the XHR task left in a `scheduled` state.\r\n\r\nNote that this repro specifically forks the root zone. If you try to repro this in StackBlitz or in Angular's `NgZone` and for the current zone instead, you'll need to wrap the `addEventListener()` call in `Zone.root.run()` to make it work. The reason is that `NgZone` implements a `onHandleError()` delegate hook that always returns false, and the exception get swallowed instead of being thrown.\r\n","author":{"url":"https://github.com/mleibman","@type":"Person","name":"mleibman"},"datePublished":"2021-04-08T20:45:18Z","url":"https://github.com/angular/angular/issues/41520"}
| 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:7ee0efa8-576b-0bfa-90e1-f01026153d3a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B324:2270F4:D684C3:11E5207:6B00FF8C |
| html-safe-nonce | 8e02760250d1814f9887d958a1ffef7f6b37ee59f44997402c729b6f1739f194 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzI0OjIyNzBGNDpENjg0QzM6MTFFNTIwNzo2QjAwRkY4QyIsInZpc2l0b3JfaWQiOiIzOTQ0MzgzNTE4NDQ4MDkxMDIwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c7a275e4ecf99cc739496581b8e9ef2b65de4c794f7cb3442889dda0da45fae0 |
| hovercard-subject-tag | issue:853885084 |
| 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/41520/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d92c5925b30ed135a89e1d638fad3a404a71b7105266e1a199e0a5dd80168758/angular/angular/issues/41520 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d92c5925b30ed135a89e1d638fad3a404a71b7105266e1a199e0a5dd80168758/angular/angular/issues/41520 |
| og:image:alt | 🐞 bug report Affected Package The issue is caused by package @angular/zone.js. Is this a regression? AFAICT it has always been like this. Description ZoneJS invokes the XHR macrotask after all exis... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mleibman |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width