This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
Note: This feature is only available in Web Workers.
The rejectionhandled event is sent to the script's global scope (typically WorkerGlobalScope) whenever a rejected Promise is handled late, i.e., when a handler is attached to the promise after its rejection had caused an unhandledrejection event.
This can be used in debugging and for general application resiliency, in tandem with the unhandledrejection event, which is sent when a promise is rejected but there is no handler for the rejection at the time.
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("rejectionhandled", (event) => { })
onrejectionhandled = (event) => { }
A PromiseRejectionEvent. Inherits from Event.
PromiseRejectionEvent.promise Read only
The Promise that was rejected.
PromiseRejectionEvent.reason Read only
A value or Object indicating why the promise was rejected, as passed to Promise.reject().
You can use the rejectionhandled event to log promises that get rejected to the console, along with the reasons why they were rejected:
self.addEventListener("rejectionhandled", (event) => {
console.log(`Promise rejected; reason: ${event.reason}`);
});
| Specification |
|---|
| HTML> # handler-workerglobalscope-onrejectionhandled> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
rejectionhandled_event |
49 | 79 | 69 | 36 | 11 | 49 | 79 | 36 | 11 | 5.0 | 49 | 11 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/rejectionhandled_event