Skip to content

Commit e0dceb4

Browse files
committed
src: discard remaining foreground tasks on platform shutdown
While V8 itself should not have any remaining tasks on the queue during platform shutdown, our inspector implementation may do so. Thus, the checks verifying that no tasks are queued at that point make some of the inspector tasks flaky. Remove the checks and replace them by explicitly destroying all tasks that are left. Refs: nodejs#25653 Refs: nodejs#28870 (comment)
1 parent 3adec43 commit e0dceb4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/node_platform.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,13 @@ void PerIsolatePlatformData::Shutdown() {
279279
if (flush_tasks_ == nullptr)
280280
return;
281281

282-
CHECK_NULL(foreground_delayed_tasks_.Pop());
283-
CHECK_NULL(foreground_tasks_.Pop());
282+
// While there should be no V8 tasks in the queues at this point, it is
283+
// possible that Node.js-internal tasks from e.g. the inspector are still
284+
// lying around. We clear these queues and ignore the return value,
285+
// effectively deleting the tasks instead of running them.
286+
foreground_delayed_tasks_.PopAll();
287+
foreground_tasks_.PopAll();
288+
284289
CancelPendingDelayedTasks();
285290

286291
ShutdownCbList* copy = new ShutdownCbList(std::move(shutdown_callbacks_));

0 commit comments

Comments
 (0)