Skip to content

Commit a2e6e00

Browse files
backeshashseed
authored andcommitted
platform: Ensure no more foreground tasks after Deinit
Node first calls Isolate::Dispose, then NodePlatform::UnregisterIsolate. This again calls PerIsolatePlatformData::Shutdown, which (before this patch) called FlushForegroundTasksInternal, which might call RunForegroundTask if it finds foreground tasks to be executed. This will fail however, since Isolate::GetCurrent was already reset during Isolate::Dispose. Hence remove the check to FlushForegroundTasksInternal and add checks instead that no more foreground tasks are scheduled.
1 parent ba15d73 commit a2e6e00

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/node_platform.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ void PerIsolatePlatformData::Shutdown() {
265265
if (flush_tasks_ == nullptr)
266266
return;
267267

268-
while (FlushForegroundTasksInternal()) {}
268+
CHECK_NULL(foreground_delayed_tasks_.Pop());
269+
CHECK_NULL(foreground_tasks_.Pop());
269270
CancelPendingDelayedTasks();
270271

271272
uv_close(reinterpret_cast<uv_handle_t*>(flush_tasks_),

0 commit comments

Comments
 (0)