feat: "rejectionhandled" Web event and "rejectionHandled" Node event (#21875)

This commit adds support for "rejectionhandled" Web Event and
"rejectionHandled" Node event.

```js
import process from "node:process";

process.on("rejectionHandled", (promise) => {
  console.log("rejectionHandled", reason, promise);
});

window.addEventListener("rejectionhandled", (event) => {
  console.log("rejectionhandled", event.reason, event.promise);
});
```

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
This commit is contained in:
Bartek Iwańczuk 2024-01-12 23:10:42 +01:00 committed by GitHub
parent 288774c5ed
commit 7471587d29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 106 additions and 1 deletions

View file

@ -12,6 +12,7 @@
declare interface WindowEventMap {
"error": ErrorEvent;
"unhandledrejection": PromiseRejectionEvent;
"rejectionhandled": PromiseRejectionEvent;
}
/** @category Web APIs */
@ -25,6 +26,9 @@ declare interface Window extends EventTarget {
onunhandledrejection:
| ((this: Window, ev: PromiseRejectionEvent) => any)
| null;
onrejectionhandled:
| ((this: Window, ev: PromiseRejectionEvent) => any)
| null;
close: () => void;
readonly closed: boolean;
alert: (message?: string) => void;