Skip to content

Commit 758648a

Browse files
committed
fix: what a silly mistake again 🫠
We should call `Isolate::Enter` because we must bind the isolate to the thread when evaluating the mod initially, but that doesn't mean it should only be bound when evaluating. Naturally, we should invoke `Isolate::Enter` even when the v8 isolate enters its loop again. What a silly mistake again 😫
1 parent dd1ded3 commit 758648a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

crates/base/src/deno_runtime.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,15 @@ impl DenoRuntime {
387387

388388
let mut js_runtime = &mut self.js_runtime;
389389

390-
unsafe { js_runtime.v8_isolate().enter() };
391-
let mut js_runtime = scopeguard::guard(&mut js_runtime, |it| unsafe {
392-
it.v8_isolate().exit();
393-
});
390+
let mod_result_rx = {
391+
unsafe { js_runtime.v8_isolate().enter() };
392+
let mut js_runtime = scopeguard::guard(&mut js_runtime, |it| unsafe {
393+
it.v8_isolate().exit();
394+
});
395+
396+
js_runtime.mod_evaluate(self.main_module_id)
397+
};
394398

395-
let mod_result_rx = js_runtime.mod_evaluate(self.main_module_id);
396399
let is_user_worker = self.conf.is_user_worker();
397400

398401
#[cfg(debug_assertions)]
@@ -421,6 +424,11 @@ impl DenoRuntime {
421424
let get_current_cpu_time_ns_fn =
422425
|| get_thread_time().context("can't get current thread time");
423426

427+
unsafe { js_runtime.v8_isolate().enter() };
428+
let mut js_runtime = scopeguard::guard(&mut js_runtime, |it| unsafe {
429+
it.v8_isolate().exit();
430+
});
431+
424432
send_cpu_metrics_fn(CPUUsageMetrics::Enter(thread_id));
425433

426434
current_cpu_time_ns = match get_current_cpu_time_ns_fn() {

0 commit comments

Comments
 (0)