Skip to content

Promise object is passed as originalException instead of rejection reason in unhandledRejection handler #20325

Description

@karolis-zukauskas

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

9.11.0

Framework Version

@sentry/electron 6.5.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

initSentry({beforeSend(event,hint){// Seems unintuitive - I'd expect rejection reason hereconsttest=hint.originalExceptioninstanceofPromise;// truereturnevent;},});

Steps to Reproduce

  1. Throw an error from an async function and do not catch it - global "unhandledRejection" Sentry handler should capture it
  2. beforeSend is invoked - inspect EventHint.originalException to find its a Promise object. Was expecting rejection reason.

See source code:

Expected Result

I expected rejection reason (e.g. the thrown error object) inside EventHint.originalException, not a Promise object. I figured I can do the following:

letoriginalException;if(hint.originalExceptioninstanceofPromise){try{awaithint.originalException;}catch(e){originalException=e;}}

But this feels dirty - what am I supposed to do with the Promise object?

Actual Result

See above.

Additional Context

No response

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions