@@ -1386,6 +1386,11 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
13861386 CHECK (!object.IsEmpty ());
13871387 }
13881388
1389+ if (!env->can_call_into_js ()) {
1390+ failed_ = true ;
1391+ return ;
1392+ }
1393+
13891394 HandleScope handle_scope (env->isolate ());
13901395 // If you hit this assertion, you forgot to enter the v8::Context first.
13911396 CHECK_EQ (env->context (), env->isolate ()->GetCurrentContext ());
@@ -1433,6 +1438,7 @@ void InternalCallbackScope::Close() {
14331438
14341439 Environment::TickInfo* tick_info = env_->tick_info ();
14351440
1441+ if (!env_->can_call_into_js ()) return ;
14361442 if (tick_info->length () == 0 ) {
14371443 env_->isolate ()->RunMicrotasks ();
14381444 }
@@ -1452,6 +1458,8 @@ void InternalCallbackScope::Close() {
14521458 CHECK_EQ (env_->current_async_id (), 0 );
14531459 CHECK_EQ (env_->trigger_id (), 0 );
14541460
1461+ if (!env_->can_call_into_js ()) return ;
1462+
14551463 if (env_->tick_callback_function ()->Call (process, 0 , nullptr ).IsEmpty ()) {
14561464 failed_ = true ;
14571465 }
@@ -4756,6 +4764,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
47564764
47574765 const int exit_code = EmitExit (&env);
47584766
4767+ env.set_can_call_into_js (false );
47594768 env.RunCleanup ();
47604769 RunAtExit (&env);
47614770 uv_key_delete (&thread_local_env);
0 commit comments