Window: rejectionhandled event

The rejectionhandled event is sent to the script's global scope (usually window but also Worker) whenever a JavaScript Promise is rejected but after the promise rejection has been handled.

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.

Bubbles No
Cancelable No
Interface PromiseRejectionEvent
Event handler property onrejectionhandled

Example

You can use the rejectionhandled event to log promises that get rejected to the console, along with the reasons why they were rejected:

window.addEventListener("rejectionhandled", event => {
  console.log("Promise rejected; reason: " + event.reason);
}, false);

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
rejectionhandled_event
49
≤79
69
68
No
36
11
49
49
68
36
11.3
5.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Window/rejectionhandled_event