diff --git a/src/env.cc b/src/env.cc index f6303e6011f54c..4aec62a99f2c50 100644 --- a/src/env.cc +++ b/src/env.cc @@ -465,6 +465,9 @@ void Environment::CheckImmediate(uv_check_t* handle) { env->RunAndClearNativeImmediates(); + if (!env->can_call_into_js()) + return; + do { MakeCallback(env->isolate(), env->process_object(), @@ -472,7 +475,7 @@ void Environment::CheckImmediate(uv_check_t* handle) { 0, nullptr, {0, 0}).ToLocalChecked(); - } while (env->immediate_info()->has_outstanding()); + } while (env->immediate_info()->has_outstanding() && env->can_call_into_js()); if (env->immediate_info()->ref_count() == 0) env->ToggleImmediateRef(false);