From 1bc4970032e934a54ad5ff952811917fb6569dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Inf=C3=BChr?= Date: Thu, 6 Apr 2023 15:37:12 +0200 Subject: [PATCH] Do not drain worker tasks on main thread --- src/node_platform.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/node_platform.cc b/src/node_platform.cc index 632217b088ee52..1fb0eab2a869cd 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -462,10 +462,9 @@ void NodePlatform::DrainTasks(Isolate* isolate) { std::shared_ptr per_isolate = ForNodeIsolate(isolate); if (!per_isolate) return; - do { - // Worker tasks aren't associated with an Isolate. - worker_thread_task_runner_->BlockingDrain(); - } while (per_isolate->FlushForegroundTasksInternal()); + // Drain foreground tasks but not worker tasks as this may cause deadlocks + // and v8::Isolate::Dispose will join V8's worker tasks for that isolate. + while (per_isolate->FlushForegroundTasksInternal()); } bool PerIsolatePlatformData::FlushForegroundTasksInternal() {