diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-02-24 22:04:56 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-03-05 22:40:02 +0100 |
commit | 753ebd742fc5da81c201dfc59fdc42cd80312ec3 (patch) | |
tree | 1c47e13b81c477b302c822a5f133df3872fbaca7 /src/node_platform.cc | |
parent | cf699a02cae81e09d694a18f857eb07503b6e66c (diff) | |
download | node-new-753ebd742fc5da81c201dfc59fdc42cd80312ec3.tar.gz |
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 <gpunathi@in.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_platform.cc')
-rw-r--r-- | src/node_platform.cc | 10 |
1 files changed, 7 insertions, 3 deletions
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> task) { Isolate* isolate = Isolate::GetCurrent(); HandleScope scope(isolate); Environment* env = Environment::GetCurrent(isolate); - InternalCallbackScope cb_scope(env, Local<Object>(), { 0, 0 }, - InternalCallbackScope::kAllowEmptyResource); - task->Run(); + if (env != nullptr) { + InternalCallbackScope cb_scope(env, Local<Object>(), { 0, 0 }, + InternalCallbackScope::kAllowEmptyResource); + task->Run(); + } else { + task->Run(); + } } void PerIsolatePlatformData::DeleteFromScheduledTasks(DelayedTask* task) { |