fix(node-core): Pass rejection reason instead of Promise as originalException#20366
Open
fix(node-core): Pass rejection reason instead of Promise as originalException#20366
Conversation
…xception In the onUnhandledRejection handler, captureException was being called with originalException set to the rejected Promise object instead of the rejection reason. This meant hint.originalException in beforeSend and downstream integrations (localVariablesAsync, extraErrorData, zoderrors) received a Promise rather than the actual error, breaking any logic that inspects it. This aligns Node with the browser SDK and the onUncaughtException handler. Fixes #20325 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts Node’s OnUnhandledRejection integration to attach the rejection reason (rather than the Promise object) as EventHint.originalException, matching browser/onUncaughtException behavior and improving beforeSend usability.
Changes:
- Update unhandled rejection handler to pass
reasonasoriginalException. - Add Vitest coverage to assert
originalExceptionis the rejection reason and the mechanism is set correctly. - Add a test asserting the integration installs a global
unhandledRejectionlistener.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/node-core/src/integrations/onunhandledrejection.ts | Fixes the hint payload to use the rejection reason as originalException. |
| packages/node-core/test/integrations/onunhandledrejection.test.ts | Adds tests validating listener installation and the updated originalException behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
size-limit report 📦
|
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.
This PR passes the rejection reason to
captureExceptionasoriginalException. Previously it was passing the promise which was useless to users.This aligns Node with browser/onUncaughtException behavior as well.
closes #20325