diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-07-04 23:34:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-04 23:34:39 +0200 |
commit | 06934db883e9ae64c7603f98051676cbcf90994f (patch) | |
tree | 3b8174a77fb53c6d7e877ce268a955c0cce9df30 /core/bindings.rs | |
parent | f7af0b01a59aaac91473e2f920137004d39a310a (diff) |
Revert "feat: add "unhandledrejection" event support (#12994)" (#15075)
This reverts commit f7af0b01a59aaac91473e2f920137004d39a310a.
Diffstat (limited to 'core/bindings.rs')
-rw-r--r-- | core/bindings.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/bindings.rs b/core/bindings.rs index 47632d00d..a88e54af7 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(); drop(state); // Drop borrow, callbacks can call back into runtime. @@ -315,7 +323,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. @@ -333,6 +340,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(); |