summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/99_main.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index f0c63df74..91d34272f 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -346,7 +346,8 @@ function promiseRejectCallback(type, promise, reason) {
}
return !!globalThis_.onunhandledrejection ||
- event.listenerCount(globalThis_, "unhandledrejection") > 0;
+ event.listenerCount(globalThis_, "unhandledrejection") > 0 ||
+ typeof internals.nodeProcessUnhandledRejectionCallback !== "undefined";
}
function promiseRejectMacrotaskCallback() {
@@ -383,6 +384,15 @@ function promiseRejectMacrotaskCallback() {
globalThis_.dispatchEvent(rejectionEvent);
globalThis_.removeEventListener("error", errorEventCb);
+ // If event was not yet prevented, try handing it off to Node compat layer
+ // (if it was initialized)
+ if (
+ !rejectionEvent.defaultPrevented &&
+ typeof internals.nodeProcessUnhandledRejectionCallback !== "undefined"
+ ) {
+ internals.nodeProcessUnhandledRejectionCallback(rejectionEvent);
+ }
+
// If event was not prevented (or "unhandledrejection" listeners didn't
// throw) we will let Rust side handle it.
if (rejectionEvent.defaultPrevented) {