Skip to content

Commit

Permalink
src: discard remaining foreground tasks on platform shutdown
Browse files Browse the repository at this point in the history
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: #25653
Refs: #28870 (comment)

PR-URL: #29587
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
  • Loading branch information
addaleax authored and Trott committed Sep 23, 2019
1 parent ab9b8e7 commit 54c4139
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/node_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,13 @@ void PerIsolatePlatformData::Shutdown() {
if (flush_tasks_ == nullptr)
return;

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

CancelPendingDelayedTasks();

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

0 comments on commit 54c4139

Please sign in to comment.