Skip to content

Commit

Permalink
fix: don’t let exits the v8 isolate twice from a thread if it failed …
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
nyannyacha committed Jan 28, 2024
1 parent 473aa8b commit ff08b2f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions crates/base/src/deno_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,13 @@ impl DenoRuntime {
op_state.put::<sb_env::EnvVars>(env_vars);
}

let mut js_runtime_mut = scopeguard::guard(&mut js_runtime, |it| unsafe {
it.v8_isolate().exit();
});

let main_module_id = js_runtime_mut
let main_module_id = js_runtime
.load_main_module(&main_module_url, mod_code)
.await?;

drop(js_runtime_mut);
unsafe {
js_runtime.v8_isolate().exit();
}

Ok(Self {
js_runtime,
Expand Down

0 comments on commit ff08b2f

Please sign in to comment.