Title: Async hook stack corruption with --unhandled-rejections=strict · Issue #60034 · nodejs/node · GitHub
Open Graph Title: Async hook stack corruption with --unhandled-rejections=strict · Issue #60034 · nodejs/node
X Title: Async hook stack corruption with --unhandled-rejections=strict · Issue #60034 · nodejs/node
Description: Version v24.3.0 (Other versions are also affected. See below.) Platform Darwin hood.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000 arm64 Also reported on Windows 11. S...
Open Graph Description: Version v24.3.0 (Other versions are also affected. See below.) Platform Darwin hood.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6...
X Description: Version v24.3.0 (Other versions are also affected. See below.) Platform Darwin hood.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6...
Opengraph URL: https://github.com/nodejs/node/issues/60034
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Async hook stack corruption with --unhandled-rejections=strict","articleBody":"### Version\n\nv24.3.0 (Other versions are also affected. See below.)\n\n### Platform\n\n```text\nDarwin hood.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000 arm64\n\nAlso reported on Windows 11.\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\nFirst, install jasmine@5.11.0. Then create runner.js as follows:\n\n```\nconst Jasmine = require(\"jasmine\");\nconst fs = require(\"fs\");\n\n(async () =\u003e {\n const runner = new Jasmine();\n\n runner.addSpecFile(\"./crash.spec.js\");\n\n runner.addReporter({\n suiteDone: async () =\u003e {\n console.log(\"\\nAbout to crash!\");\n await fs.promises.readFile(\"./package.json\");\n },\n });\n\n await runner.execute();\n})();\n```\n\nAnd create crash.spec.js as follows:\n\n```\ndescribe('a suite that crashes NodeJS', () =\u003e {\n it('throws twice', async () =\u003e {\n await new Promise((resolve, reject) =\u003e {\n setTimeout(() =\u003e {\n reject(new Error('foo'));\n }, 0);\n }).foo();\n });\n});\n```\n\nFinally, run `node --unhandled-rejections=strict runner.js`.\n\nI tried and failed to reduce this down to a simple code snippet with no dependencies. The user who reported it to me [stated that it took them two days to reproduce it to this point](https://github.com/jasmine/jasmine/issues/2076). \n\n### How often does it reproduce? Is there a required condition?\n\nReproduces 100% of the time with (at least) 20.19.0, 22.14.0, 24.0.0, and 24.3.0. It's also been reported on \u003e= 22.3.0. Does not reproduce with 20.0.0 or 22.0.0.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nNode should not crash. The script should run to completion and produce output like the following:\n\n```\nRandomized with seed 36538\nStarted\nF\nAbout to crash!\n\n\nFailures:\n1) a suite that crashes NodeJS throws twice\n Message:\n TypeError: (intermediate value).foo is not a function\n Stack:\n at UserContext.\u003canonymous\u003e (/Users/steve/Downloads/no-zip/crash.spec.js:7:12)\n at \u003cJasmine\u003e\n\nSuite error: top suite\n Message:\n Uncaught exception: Error: foo\n Stack:\n at Timeout._onTimeout (/Users/steve/Downloads/no-zip/crash.spec.js:5:24)\n at listOnTimeout (node:internal/timers:573:17)\n at process.processTimers (node:internal/timers:514:7)\n Message:\n Unhandled promise rejection: Error: foo\n Stack:\n at Timeout._onTimeout (/Users/steve/Downloads/no-zip/crash.spec.js:5:24)\n at listOnTimeout (node:internal/timers:573:17)\n at process.processTimers (node:internal/timers:514:7)\n\n1 spec, 3 failures\nFinished in 0.007 seconds\nRandomized with seed 36538 (jasmine --random=true --seed=36538)\n```\n\n### What do you see instead?\n\n```\nRandomized with seed 66384\nStarted\nF\nAbout to crash!\n\n # node[9176]: void node::AsyncHooks::push_async_context(double, double, Local\u003cObject\u003e) at ../src/env.cc:130\n # Assertion failed: (trigger_async_id) \u003e= (-1)\n\n----- Native stack trace -----\n\n 1: 0x10019f040 node::Assert(node::AssertionInfo const\u0026) [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n 2: 0x102236be0 node::AsyncHooks::push_async_context(double, double, v8::Local\u003cv8::Object\u003e) (.cold.2) [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n 3: 0x1000dc85c node::AsyncHooks::grow_async_ids_stack() [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n 4: 0x100098cb4 node::InternalCallbackScope::InternalCallbackScope(node::Environment*, v8::Local\u003cv8::Object\u003e, node::async_context const\u0026, int, v8::Local\u003cv8::Value\u003e) [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n 5: 0x100098da0 node::InternalCallbackScope::InternalCallbackScope(node::AsyncWrap*, int) [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n 6: 0x100196cd4 node::fs::FSReqPromise\u003cnode::AliasedBufferBase\u003cdouble, v8::Float64Array\u003e\u003e::Resolve(v8::Local\u003cv8::Value\u003e) [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n 7: 0x1001a5850 node::fs::AfterStat(uv_fs_s*) [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n 8: 0x1001973a8 node::MakeLibuvRequestCallback\u003cuv_fs_s, void (*)(uv_fs_s*)\u003e::Wrapper(uv_fs_s*) [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n 9: 0x100fd12c4 uv__work_done [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n10: 0x100fd4ff4 uv__async_io [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n11: 0x100fe938c uv__io_poll [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n12: 0x100fd555c uv_run [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n13: 0x100099a98 node::SpinEventLoopInternal(node::Environment*) [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n14: 0x1001eb704 node::NodeMainInstance::Run() [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n15: 0x100159474 node::Start(int, char**) [/Users/steve/.nvm/versions/node/v24.3.0/bin/node]\n16: 0x19fc1ab98 start [/usr/lib/dyld]\nzsh: abort node --unhandled-rejections=strict runner.js\n```\n\n### Additional information\n\nIf I replace ` await fs.promises.readFile(\"./package.json\");` with `await new Promise(resolve =\u003e setTimeout(resolve));` in runner.js, I sometimes get an early exit instead of a crash. It's easiest to see that if you patch `node_modules/jasmine/lib/jasmine.js` as follows:\n\n```diff\n@@ -239,7 +239,7 @@\n this.addMatchingSpecFiles(files);\n }\n \n- const prematureExitHandler = new ExitHandler(() =\u003e this.exit(4));\n+ const prematureExitHandler = new ExitHandler(() =\u003e console.error('premature exit!'));\n prematureExitHandler.install();\n let overallResult;\n```","author":{"url":"https://github.com/sgravrock","@type":"Person","name":"sgravrock"},"datePublished":"2025-09-27T18:18:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/60034/node/issues/60034"}
| 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:163568d7-5857-aa67-a704-383c8156f6c9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C9EE:9B927:D9EA49:13BDADC:6A4CC54C |
| html-safe-nonce | ac3efa3e03093b722fee5e9ae16b6a1858bdca9a1d76b864bd3e774ee484dcc4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUVFOjlCOTI3OkQ5RUE0OToxM0JEQURDOjZBNENDNTRDIiwidmlzaXRvcl9pZCI6IjUwMzM3NzE1Nzc1ODMxMjU4MzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 49ae7e93c7ddea67e5c1468be391b6243dbf1a3673e9118cc16851709820c91a |
| hovercard-subject-tag | issue:3460592457 |
| 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/60034/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d4e11b5b0d70c4233740ba03844bb2e490627c04a3d4197ffbf8d31d3ddd335/nodejs/node/issues/60034 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d4e11b5b0d70c4233740ba03844bb2e490627c04a3d4197ffbf8d31d3ddd335/nodejs/node/issues/60034 |
| og:image:alt | Version v24.3.0 (Other versions are also affected. See below.) Platform Darwin hood.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sgravrock |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| 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 | d0da0eb92994395299ed4450bf67b0373005be36 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width