mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
Relanding #12994 This commit adds support for "unhandledrejection" event. This event will trigger event listeners registered using: "globalThis.addEventListener("unhandledrejection") "globalThis.onunhandledrejection" This is done by registering a default handler using "Deno.core.setPromiseRejectCallback" that allows to handle rejected promises in JavaScript instead of Rust. This commit will make it possible to polyfill "process.on("unhandledRejection")" in the Node compat layer. Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
48a7312f38
commit
1a7259b04b
10 changed files with 213 additions and 10 deletions
11
cli/dts/lib.deno.shared_globals.d.ts
vendored
11
cli/dts/lib.deno.shared_globals.d.ts
vendored
|
@ -400,6 +400,17 @@ declare class ErrorEvent extends Event {
|
|||
constructor(type: string, eventInitDict?: ErrorEventInit);
|
||||
}
|
||||
|
||||
interface PromiseRejectionEventInit extends EventInit {
|
||||
promise: Promise<any>;
|
||||
reason?: any;
|
||||
}
|
||||
|
||||
declare class PromiseRejectionEvent extends Event {
|
||||
readonly promise: Promise<any>;
|
||||
readonly reason: any;
|
||||
constructor(type: string, eventInitDict?: PromiseRejectionEventInit);
|
||||
}
|
||||
|
||||
interface AbstractWorkerEventMap {
|
||||
"error": ErrorEvent;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue