diff --git a/src/node_platform.cc b/src/node_platform.cc index da28de0a844929..9b1c4b4ca9bebd 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -334,9 +334,13 @@ void PerIsolatePlatformData::RunForegroundTask(std::unique_ptr task) { Isolate* isolate = Isolate::GetCurrent(); HandleScope scope(isolate); Environment* env = Environment::GetCurrent(isolate); - InternalCallbackScope cb_scope(env, Local(), { 0, 0 }, - InternalCallbackScope::kAllowEmptyResource); - task->Run(); + if (env != nullptr) { + InternalCallbackScope cb_scope(env, Local(), { 0, 0 }, + InternalCallbackScope::kAllowEmptyResource); + task->Run(); + } else { + task->Run(); + } } void PerIsolatePlatformData::DeleteFromScheduledTasks(DelayedTask* task) {