Skip to content

Commit 9c277c0

Browse files
addaleaxBridgeAR
authored andcommitted
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: #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>
1 parent 622048d commit 9c277c0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/node_platform.cc

+7-3
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,13 @@ void PerIsolatePlatformData::RunForegroundTask(std::unique_ptr<Task> task) {
334334
Isolate* isolate = Isolate::GetCurrent();
335335
HandleScope scope(isolate);
336336
Environment* env = Environment::GetCurrent(isolate);
337-
InternalCallbackScope cb_scope(env, Local<Object>(), { 0, 0 },
338-
InternalCallbackScope::kAllowEmptyResource);
339-
task->Run();
337+
if (env != nullptr) {
338+
InternalCallbackScope cb_scope(env, Local<Object>(), { 0, 0 },
339+
InternalCallbackScope::kAllowEmptyResource);
340+
task->Run();
341+
} else {
342+
task->Run();
343+
}
340344
}
341345

342346
void PerIsolatePlatformData::DeleteFromScheduledTasks(DelayedTask* task) {

0 commit comments

Comments
 (0)