From 753ebd742fc5da81c201dfc59fdc42cd80312ec3 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 24 Feb 2019 22:04:56 +0100 Subject: src: allow running tasks without `Environment` There is no real reason to assume that V8 tasks would have to run in a Node.js `Context`. PR-URL: https://github.com/nodejs/node/pull/26376 Reviewed-By: Gireesh Punathil Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/node_platform.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/node_platform.cc') diff --git a/src/node_platform.cc b/src/node_platform.cc index da28de0a84..9b1c4b4ca9 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) { -- cgit v1.2.3