summaryrefslogtreecommitdiff
path: root/core/bindings.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-07-18 21:20:38 +0200
committerGitHub <noreply@github.com>2022-07-18 21:20:38 +0200
commit9eb70bdb5fda8e66895e0e4cc1f356c2717f74c5 (patch)
tree4132d7b8ff358fc09dcf93a8c0c62826f9d271af /core/bindings.rs
parent70d1ecaeaa7843b37e8ea5161b24988813b2f543 (diff)
reland: "fix(core): unhandled rejection in top-level scope" (#15236)
Reland #15204
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 f9fd1f402..66c3e436d 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -333,12 +333,20 @@ pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
// 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.
let tc_scope = &mut v8::TryCatch::new(scope);
let undefined: v8::Local<v8::Value> = v8::undefined(tc_scope).into();
let type_ = v8::Integer::new(tc_scope, message.get_event() as i32);
let promise = message.get_promise();
+ if let Some(pending_mod_evaluate) = state.pending_mod_evaluate.as_mut() {
+ if !pending_mod_evaluate.has_evaluated {
+ let promise_global = v8::Global::new(tc_scope, promise);
+ pending_mod_evaluate
+ .handled_promise_rejections
+ .push(promise_global);
+ }
+ }
+ drop(state); // Drop borrow, callbacks can call back into runtime.
let reason = match message.get_event() {
PromiseRejectWithNoHandler