summaryrefslogtreecommitdiff
path: root/core/bindings.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-07-15 01:06:20 +0200
committerGitHub <noreply@github.com>2022-07-15 01:06:20 +0200
commitf9b692e68e97ab6d39ad03988e973279a32cceca (patch)
tree9ae831322bee0a7226cb725e15e7332f6ab89ebe /core/bindings.rs
parent91a33c65f3bdc82bef4cbe95f614e1f533e5b368 (diff)
Revert "feat: add "unhandledrejection" event support (#12994) (#15080)" (#15210)
This reverts commit 1a7259b04b7229f6350a7a7c21b50497b5c80c17.
Diffstat (limited to 'core/bindings.rs')
-rw-r--r--core/bindings.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/bindings.rs b/core/bindings.rs
index c9e27f087..49dc62c0e 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -282,6 +282,14 @@ pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
let state_rc = JsRuntime::state(scope);
let mut state = state_rc.borrow_mut();
+ // Node compat: perform synchronous process.emit("unhandledRejection").
+ //
+ // Note the callback follows the (type, promise, reason) signature of Node's
+ // internal promiseRejectHandler from lib/internal/process/promises.js, not
+ // the (promise, reason) signature of the "unhandledRejection" event listener.
+ //
+ // Short-circuits Deno's regular unhandled rejection logic because that's
+ // a) asynchronous, and b) always terminates.
if let Some(js_promise_reject_cb) = state.js_promise_reject_cb.clone() {
let js_uncaught_exception_cb = state.js_uncaught_exception_cb.clone();
@@ -323,7 +331,6 @@ pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
}
if tc_scope.has_caught() {
- // TODO(bartlomieju): ensure that TODO provided below is still valid.
// If we get here, an exception was thrown by the unhandledRejection
// handler and there is ether no uncaughtException handler or the
// handler threw an exception of its own.
@@ -341,6 +348,7 @@ pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
} else {
let promise = message.get_promise();
let promise_global = v8::Global::new(scope, promise);
+
match message.get_event() {
PromiseRejectWithNoHandler => {
let error = message.get_value().unwrap();