Skip to content

Commit

Permalink
src: allow running tasks without Environment
Browse files Browse the repository at this point in the history
There is no real reason to assume that V8 tasks would have
to run in a Node.js `Context`.

PR-URL: nodejs#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>
  • Loading branch information
addaleax authored and BridgeAR committed Mar 12, 2019
1 parent 622048d commit 9c277c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/node_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9c277c0

Please sign in to comment.