diff --git a/crates/isolate/src/environment/action/mod.rs b/crates/isolate/src/environment/action/mod.rs index 5774d5e0..ce4de45e 100644 --- a/crates/isolate/src/environment/action/mod.rs +++ b/crates/isolate/src/environment/action/mod.rs @@ -1105,11 +1105,16 @@ impl ActionEnvironment { .remove(&task_id) else { anyhow::bail!("Task with id {} did not have a promise", task_id); }; + let mut result_scope = v8::HandleScope::new(&mut **scope); let result_v8 = match variant { - Ok(v) => Ok(v.into_v8(scope)?), + Ok(v) => Ok(v.into_v8(&mut result_scope)?), Err(e) => Err(e), }; - resolve_promise_allow_all_errors(scope, resolver, result_v8)?; + resolve_promise_allow_all_errors( + &mut result_scope, + resolver, + result_v8, + )?; }, }; }, diff --git a/crates/isolate/src/environment/udf/mod.rs b/crates/isolate/src/environment/udf/mod.rs index da62d67e..1ae41954 100644 --- a/crates/isolate/src/environment/udf/mod.rs +++ b/crates/isolate/src/environment/udf/mod.rs @@ -738,11 +738,12 @@ impl DatabaseUdfEnvironment { // Complete the syscall's promise, which will put its handlers on the microtask // queue. for (resolver, result) in resolvers.into_iter().zip(results.into_iter()) { + let mut result_scope = v8::HandleScope::new(&mut *scope); let result_v8 = match result { - Ok(v) => Ok(serde_v8::to_v8(&mut scope, v)?), + Ok(v) => Ok(serde_v8::to_v8(&mut result_scope, v)?), Err(e) => Err(e), }; - resolve_promise(&mut scope, resolver, result_v8)?; + resolve_promise(&mut result_scope, resolver, result_v8)?; } handle.check_terminated()?; }