Title: ZoneJS: legacy Object.defineProperty patch breaks configurable descriptor attribute · Issue #37432 · angular/angular · GitHub
Open Graph Title: ZoneJS: legacy Object.defineProperty patch breaks configurable descriptor attribute · Issue #37432 · angular/angular
X Title: ZoneJS: legacy Object.defineProperty patch breaks configurable descriptor attribute · Issue #37432 · angular/angular
Description: bug report Affected Package zone.js Is this a regression? Yes, but super back in the past! It broke with v0.6.24. Description ZoneJS has this super old legacy Object.defineProperty patch that basically partially re-implements the Object....
Open Graph Description: bug report Affected Package zone.js Is this a regression? Yes, but super back in the past! It broke with v0.6.24. Description ZoneJS has this super old legacy Object.defineProperty patch that basic...
X Description: bug report Affected Package zone.js Is this a regression? Yes, but super back in the past! It broke with v0.6.24. Description ZoneJS has this super old legacy Object.defineProperty patch that basic...
Opengraph URL: https://github.com/angular/angular/issues/37432
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ZoneJS: legacy Object.defineProperty patch breaks configurable descriptor attribute","articleBody":"\u003c!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅\r\n\r\nOh hi there! 😄\r\n\r\nTo expedite issue processing please search open and closed issues before submitting a new one.\r\nExisting issues often contain information about workarounds, resolution, or progress updates.\r\n\r\n🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->\r\n\r\n\r\n# bug report\r\n\r\n### Affected Package\r\n\r\nzone.js\r\n\r\n### Is this a regression?\r\n\r\nYes, but super back in the past! It broke with v0.6.24.\r\n\r\n### Description\r\n\r\nZoneJS has this super old legacy `Object.defineProperty` patch that basically partially re-implements\r\nthe `Object.defineProperty` functionality in order to resolve some custom elements issue. I'm confident that these issues are no longer surfacing and patching `Object.defineProperty` is not the right solution these days.\r\n\r\nThe issue is that this overwritten `Object.defineProperty` function behaves different to the native implementation. i.e. by default defined properties are not configurable. In ZoneJS, with the patched version, properties are _always_ configurable. This means that:\r\n\r\n1. The default `configurable` property descriptor attribute is not respected.\r\n2. Defined properties are by default always `configurable: true`. This doesn't match the native implementation.\r\n\r\nDue to these inconsistencies, ZoneJS could potentially hide app issues that would usually cause errors in production. e.g. when using differential loading, legacy patches might be used in tests, but not always in production. So, calling `defineProperty` multiple times in your app might work with the legacy patches in tests and legacy browsers, but otherwise cause a `Uncaught TypeError: Cannot redefine property: X` error in evergreen browsers.\r\n\r\nWe saw this issue in the Angular Material test harnesses: https://github.com/angular/components/issues/19440\r\n\r\nHere is the commit that introduced this logic back in the old repository:\r\nhttps://github.com/angular/zone.js/commit/383b47905d0a55c0fd87983fa6effd0278cf70f1. And here is the commit that caused the incorrect `configurable` default, and the flag to be not respected at all: https://github.com/angular/zone.js/commit/7b7258b9bf0b4ffd944b2ae015bfb5cb045e3c05.\r\n\r\n## Minimal Reproduction\r\n\r\n```ts\r\nconst x = {}\r\nObject.defineProperty(x, 'defaultPrevented', { get: () => true, configurable: false });\r\nconsole.error(Object.getOwnPropertyDescriptor(x, 'defaultPrevented'));\r\n```\r\n\r\nThis prints `configurable: false` for the `defaultPrevented` property without ZoneJS. If the ZoneJS legacy patches are loaded, this is not the case though and `configurable` is always `true`.\r\n\r\n## Exception or Error\r\n\r\n`Object.defineProperty` behaves different depending on whether ZoneJS legacy patches are loaded or not. ZoneJS could **hide app failures** in tests as `Object.defineProperty` never sets `configurable: false` while in reality, defining a non-configurable property again, causes a `Cannot redeclare property X` runtime error in browsers.\r\n\r\n## Your Environment\r\n\r\n**Angular Version:**\r\n\r\nAngular v10.0.0-rc.2.\r\nzonejs: 0.10.\r\n\r\n**Anything else relevant?**\r\n\r\nWe should audit if we still need this legacy patch. I'm confident, we wouldn't. I'm hoping we can remove this as it's prone to inconsistencies with the native `Object.defineProperty` behavior. ","author":{"url":"https://github.com/devversion","@type":"Person","name":"devversion"},"datePublished":"2020-06-04T08:56:27Z","url":"https://github.com/angular/angular/issues/37432"}
| 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:0bc67ce0-39d5-a9a1-f83f-1aa9a8684aec |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7AA:4D9F2:18DA0DF:20F92F2:6B0213AE |
| html-safe-nonce | f59d85a8ab380a927dec9ec916f97034389a093c87396f75e32ec26a911b4ad1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0FBOjREOUYyOjE4REEwREY6MjBGOTJGMjo2QjAyMTNBRSIsInZpc2l0b3JfaWQiOiI4NjcyMjA0NjIyNjA4NTE2MzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b4a19c25d8069f5107084d9877e8adf64c2bf3b2ba5651feac8a36b05f645de6 |
| hovercard-subject-tag | issue:630639918 |
| 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/37432/issue_layout |
| twitter:image | https://opengraph.githubassets.com/86a361e4f4d25afddb7163dfa6a2e155cc4d37ac22ceb28a514883c9e6250482/angular/angular/issues/37432 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/86a361e4f4d25afddb7163dfa6a2e155cc4d37ac22ceb28a514883c9e6250482/angular/angular/issues/37432 |
| og:image:alt | bug report Affected Package zone.js Is this a regression? Yes, but super back in the past! It broke with v0.6.24. Description ZoneJS has this super old legacy Object.defineProperty patch that basic... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devversion |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width