diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-07-14 21:01:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-14 21:01:08 +0200 |
commit | 48a7312f3871e3b76c51eb0143ca1c48da43b20c (patch) | |
tree | 21c11d91975e6b71f8341709def829385258a3e4 /core/bindings.rs | |
parent | bc7cb61d1a1bc7e55968310b5eed3ec1d911ad18 (diff) |
fix(core): unhandled rejection in top-level scope (#15204)
Update "deno_core" to not forward rejection of top level module
if it was already handled by appropriate handlers.
Co-authored-by: Colin Ihrig cjihrig@gmail.com
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 a88e54af7..49dc62c0e 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -292,12 +292,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 |