Errors not shown - How to workaround non-existent `onunhandledrejection`

If there is error in async function UXP won’t tell you it. Also I want to integrate Sentry.

I can add Sentry for Browser. I can also explicitly send an error calling sentry function and it works. But it does not catch unhadled rejections automatically. Because onunhandledrejection is not implemented in UXP.

Sentry listents to that event but UXP will never fire it. Also unhandled rejection is never logged into console by default. I have to use try/catch and rethrow it myslef.

Is there some a way to workaround it? I was thinking maybe to intercept Error constructor or something like that but it did not work. And Error.captureStackTrace is called in so many non-error cases that I cannot use it.

I can wrap top level code into try/catch call Sentry explicitly and it works for awaited child functions but if some nested promise is not awaited then it is not catched and error not reported.


+1 For this issue. We really need better errors in UXP for debugging and error reporting with systems like Sentry.

1 Like

I third this motion.

Agreed. Gets cumbersome and error prone to manage potential for rejected promises with things like button handlers.

I asked Sentry for workaround. They don’t see any good one. How to workaround non-existent `onunhandledrejection` in Adobe UXP (Javascript) · getsentry/sentry-javascript · Discussion #12338 · GitHub

I also agree. I have Sentry integrated into one of my plugins, but I am wrapping the code in try/catch as you mentioned. I only added it to parts which I think are critical but it’s cumbersome and I may miss errors.

1 Like

This works in Chrome but I can’t make it work in UXP GitHub - rtsao/browser-unhandled-rejection: A ponyfill/polyfill for browser Promise unhandledrejection events

Can anyone figure out why?