Title: Async hooks cause programs with frozen promises to crash · Issue #42229 · nodejs/node · GitHub
Open Graph Title: Async hooks cause programs with frozen promises to crash · Issue #42229 · nodejs/node
X Title: Async hooks cause programs with frozen promises to crash · Issue #42229 · nodejs/node
Description: Version v16.13.1 Platform Darwin MacBook-Pro 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64 Subsystem No response What steps will reproduce the bug? Type the following i...
Open Graph Description: Version v16.13.1 Platform Darwin MacBook-Pro 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64 Subsystem No response What steps will...
X Description: Version v16.13.1 Platform Darwin MacBook-Pro 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64 Subsystem No response What steps will...
Opengraph URL: https://github.com/nodejs/node/issues/42229
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Async hooks cause programs with frozen promises to crash","articleBody":"### Version\n\nv16.13.1\n\n### Platform\n\nDarwin MacBook-Pro 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\nType the following interactively at the Node shell.\r\n\r\n```js\r\n~$ node\r\nWelcome to Node.js v16.13.1.\r\nType \".help\" for more information.\r\n> const p = Promise.resolve(8);\r\nundefined\r\n> const names = Reflect.ownKeys(p);\r\nundefined\r\n> names\r\n[\r\n 'domain',\r\n Symbol(async_id_symbol),\r\n Symbol(trigger_async_id_symbol),\r\n Symbol(destroyed)\r\n]\r\n> for (const name of names) {\r\n... delete p[name];\r\n... }\r\ntrue\r\n> Object.freeze(p);\r\nPromise { 8 }\r\n> const q = p.then(x => console.log(x));\r\nUncaught:\r\nTypeError: Cannot add property Symbol(async_id_symbol), object is not extensible\r\n at getOrSetAsyncId (node:internal/async_hooks:424:34)\r\n at trackPromise (node:internal/async_hooks:314:35)\r\n at promiseInitHook (node:internal/async_hooks:322:3)\r\n at promiseInitHookWithDestroyTracking (node:internal/async_hooks:329:3)\r\n at Promise.then (\u003canonymous>)\r\n> undefined\r\n> 8\r\n```\r\nThe 'domain' property is not the main concern here. Rather it is the other three symbols. Hardened JS (aka SES) avoid loading the module that would add 'domain'. However, at the vscode debug terminal, we get a result much like the above but without 'domain' showing up in the list of names. Other differences between the following and the previous section are probably due to the differences caused by Hardened JS and might or might now be relevant. Other than the expected absence of 'domain', the underlying Node bug is the same:\r\n\r\nIn the debug console:\r\n```js\r\np = Promise.resolve(8);\r\nPromise {[[PromiseState]]: 'fulfilled', [[PromiseResult]]: 8, Symbol(async_id_symbol): 3543, Symbol(trigger_async_id_symbol): 1783, Symbol(destroyed): {…}}\r\nnames = Reflect.ownKeys(p);\r\n(3) [Symbol(async_id_symbol), Symbol(trigger_async_id_symbol), Symbol(destroyed)]\r\nfor (const name of names) {\r\n delete p[name];\r\n}\r\ntrue\r\nObject.freeze(p);\r\nPromise {[[PromiseState]]: 'fulfilled', [[PromiseResult]]: 8}\r\nq = p.then(x => console.log(x));\r\n```\r\nThat last line will terminate the debug session, with the following error appearing on vscode's JavaScript Debug Terminal\r\n```js\r\nDebugger attached.\r\n - range queries\r\n\r\n Uncaught exception in test/test-rankOrder.js\r\n\r\n TypeError: Cannot add property Symbol(async_id_symbol), object is not extensible\r\n at Promise.then (\u003canonymous>)\r\n at eval (eval at \u003canonymous> (packages/store/test/test-rankOrder.js:94:7), \u003canonymous>:1:13)\r\n at packages/store/test/test-rankOrder.js:94:7\r\n at packages/store/test/test-rankOrder.js:90:12\r\n at async Promise.all (index 7)\r\n\r\n › Promise.then (\u003canonymous>)\r\n › eval (eval at \u003canonymous> (packages/store/test/test-rankOrder.js:94:7), \u003canonymous>:1:13)\r\n › packages/store/test/test-rankOrder.js:94:7\r\n › packages/store/test/test-rankOrder.js:90:12\r\n\r\n(TypeError#1)\r\nWaiting for the debugger to disconnect...\r\nTypeError#1: Cannot add property Symbol(async_id_symbol), object is not extensible\r\n at Promise.then (\u003canonymous>)\r\n at eval (eval at \u003canonymous> (packages/store/test/test-rankOrder.js:94:7), \u003canonymous>:1:13)\r\n at packages/store/test/test-rankOrder.js:94:7\r\n at packages/store/test/test-rankOrder.js:90:12\r\n at async Promise.all (index 7)\r\n\r\n ✖ test/test-rankOrder.js exited with a non-zero exit code: 1\r\n ─\r\n\r\n 1 test skipped\r\n 1 uncaught exception\r\nWaiting for the debugger to disconnect...\r\nerror Command failed with exit code 1.\r\ninfo Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\r\nWaiting for the debugger to disconnect...\r\nWaiting for the debugger to disconnect...\r\n```\r\nPutting the same code in a .js file and executing it non-interactively does not trigger the bug. The `names` array in that case is empty, as it should be.\n\n### How often does it reproduce? Is there a required condition?\n\nIt reproduces reliably. The explanation above should be adequate to reliably reproduce it. Please let me know if you have any trouble reproducing it.\n\n### What is the expected behavior?\n\n`names` should be empty.\r\n`q` should be defined as a promise that eventually fulfills to p's fulfillment, 8.\n\n### What do you see instead?\n\nAs presented above:\r\n```js\r\n~$ node\r\nWelcome to Node.js v16.13.1.\r\nType \".help\" for more information.\r\n> const p = Promise.resolve(8);\r\nundefined\r\n> const names = Reflect.ownKeys(p);\r\nundefined\r\n> names\r\n[\r\n 'domain',\r\n Symbol(async_id_symbol),\r\n Symbol(trigger_async_id_symbol),\r\n Symbol(destroyed)\r\n]\r\n> for (const name of names) {\r\n... delete p[name];\r\n... }\r\ntrue\r\n> Object.freeze(p);\r\nPromise { 8 }\r\n> const q = p.then(x => console.log(x));\r\nUncaught:\r\nTypeError: Cannot add property Symbol(async_id_symbol), object is not extensible\r\n at getOrSetAsyncId (node:internal/async_hooks:424:34)\r\n at trackPromise (node:internal/async_hooks:314:35)\r\n at promiseInitHook (node:internal/async_hooks:322:3)\r\n at promiseInitHookWithDestroyTracking (node:internal/async_hooks:329:3)\r\n at Promise.then (\u003canonymous>)\r\n> undefined\r\n> 8\r\n```\r\n\n\n### Additional information\n\nGoogling led me to\r\nhttps://stackoverflow.com/questions/70742387/where-can-i-find-any-docs-on-why-node-14-changed-promise-into-promise-undefi\r\nwhich led me to\r\nhttps://github.com/nodejs/node/commit/f37c26b8a2e10d0a53a60a2fad5b0133ad33308a\r\nand\r\nhttps://github.com/nodejs/node/pull/36394\r\n\r\nHowever, that PR shows Closed rather than Merged, so it may not actually be the source of the bug.","author":{"url":"https://github.com/erights","@type":"Person","name":"erights"},"datePublished":"2022-03-06T04:11:47Z","url":"https://github.com/nodejs/node/issues/42229"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:48a7f7d6-33ba-0595-8e5d-4d9f184d5f38 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 91CE:36779:566827:750E21:6AED1FBE |
| html-safe-nonce | 72a743c635fc3c995ebeba587b57e520e5310273927c0cd361bf22ed1b568cd2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MUNFOjM2Nzc5OjU2NjgyNzo3NTBFMjE6NkFFRDFGQkUiLCJ2aXNpdG9yX2lkIjoiNTkwNDgzODU5Nzg4NDU4Mzg3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a11e51253072022b2bbe5eccc01a2f9e6848abdc95925fae054eb0997de0285e |
| hovercard-subject-tag | issue:1160512730 |
| 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/nodejs/node/42229/issue_layout |
| twitter:image | https://opengraph.githubassets.com/55ab9e1c9b6fef5b8d2db5454cf906051aed5764f1fed347d6c8a0d5b68ff55b/nodejs/node/issues/42229 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/55ab9e1c9b6fef5b8d2db5454cf906051aed5764f1fed347d6c8a0d5b68ff55b/nodejs/node/issues/42229 |
| og:image:alt | Version v16.13.1 Platform Darwin MacBook-Pro 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64 Subsystem No response What steps will... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | erights |
| hostname | github.com |
| expected-hostname | github.com |
| None | e3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| 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 | 707a24b346ac8a82878b9c084efaa38a997660cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width