Skip to content

Commit ff08b2f

Browse files
committed
fix: don’t let exits the v8 isolate twice from a thread if it failed to initialize
After exiting the V8 loop with an exception during main script initialization, an isolate was explicitly detached from the thread by `scopeguard`. Turns out an isolate calls the logic to detach itself from the thread when it is dropped by default, so the introduction of `scopeguard` was wrong. (cherry picked from commit 5359280978dacf6e80a603a0b1ea0344c74b6270)
1 parent 473aa8b commit ff08b2f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

crates/base/src/deno_runtime.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,13 @@ impl DenoRuntime {
345345
op_state.put::<sb_env::EnvVars>(env_vars);
346346
}
347347

348-
let mut js_runtime_mut = scopeguard::guard(&mut js_runtime, |it| unsafe {
349-
it.v8_isolate().exit();
350-
});
351-
352-
let main_module_id = js_runtime_mut
348+
let main_module_id = js_runtime
353349
.load_main_module(&main_module_url, mod_code)
354350
.await?;
355351

356-
drop(js_runtime_mut);
352+
unsafe {
353+
js_runtime.v8_isolate().exit();
354+
}
357355

358356
Ok(Self {
359357
js_runtime,

0 commit comments

Comments
 (0)