fix(ext/node): wrap non-Error unhandled rejections in ERR_UNHANDLED_REJECTION#32535
Merged
bartlomieju merged 4 commits intomainfrom Mar 12, 2026
Merged
fix(ext/node): wrap non-Error unhandled rejections in ERR_UNHANDLED_REJECTION#32535bartlomieju merged 4 commits intomainfrom
bartlomieju merged 4 commits intomainfrom
Conversation
…EJECTION When a promise is rejected with a non-Error value (e.g. `Promise.reject(null)`) and there are no `unhandledRejection` listeners, Node.js wraps the rejection reason in an `ERR_UNHANDLED_REJECTION` error before passing it to `uncaughtException`. Deno was passing the raw value directly, causing crashes when handlers tried to access `.message` or `.name` on the reason. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kajukitli
approved these changes
Mar 11, 2026
Contributor
kajukitli
left a comment
There was a problem hiding this comment.
lgtm, clean fix
wrapping non-Error rejections in ERR_UNHANDLED_REJECTION matches Node.js behavior. the message format looks correct too.
one minor note: you might want to preserve the original rejection value somewhere on the error (Node.js uses err.reason for this I think). but if the test passes without it, probably fine for now.
nathanwhit
reviewed
Mar 12, 2026
Node.js attaches the original rejection reason as a `reason` property on the wrapped ERR_UNHANDLED_REJECTION error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Promise.reject(null)) and there are nounhandledRejectionlisteners, Node.js wraps the rejection reason in anERR_UNHANDLED_REJECTIONerror before routing it touncaughtException. Deno was passing the raw value directly, which caused crashes when exception handlers accessed.messageor.name.test-promise-unhandled-default.jsin the node compat test suite (also unblockstest-promise-unhandled-throw.jswhich tests the same wrapping logic under--unhandled-rejections=throw).Test plan
cargo test --test node_compat test-promise-unhandled-defaultpasses (was failing before)v8.promiseHooks,--unhandled-rejectionsflag, andprocess.on('multipleResolves'))🤖 Generated with Claude Code