File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ class WorkerThreadsTaskRunner::DelayedTaskScheduler {
117117 double delay_in_seconds) {
118118 auto locked = tasks_.Lock ();
119119
120+ if (has_shut_down_) return ;
121+
120122 auto entry = std::make_unique<TaskQueueEntry>(std::move (task), priority);
121123 auto delayed = std::make_unique<ScheduleTask>(
122124 this , std::move (entry), delay_in_seconds);
@@ -132,6 +134,7 @@ class WorkerThreadsTaskRunner::DelayedTaskScheduler {
132134
133135 void Stop () {
134136 auto locked = tasks_.Lock ();
137+ has_shut_down_ = true ;
135138 locked.Push (std::make_unique<StopTask>(this ));
136139 uv_async_send (&flush_tasks_);
137140 }
@@ -241,6 +244,7 @@ class WorkerThreadsTaskRunner::DelayedTaskScheduler {
241244 uv_loop_t loop_;
242245 uv_async_t flush_tasks_;
243246 std::unordered_set<uv_timer_t *> timers_;
247+ bool has_shut_down_ = false ;
244248};
245249
246250WorkerThreadsTaskRunner::WorkerThreadsTaskRunner (
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ // Ref: https://github.com/nodejs/node/issues/56645
3+ const common = require ( '../common' ) ;
4+ const assert = require ( 'assert' ) ;
5+ const cp = require ( 'child_process' ) ;
6+ const http = require ( 'http' ) ;
7+
8+ if ( process . argv [ 2 ] === 'child' ) {
9+ http
10+ . createServer ( ( _ , res ) => {
11+ res . writeHead ( 302 , { Location : '/' } ) ;
12+ res . end ( ) ;
13+ } )
14+ . listen ( 0 , '127.0.0.1' , async function ( ) {
15+ try {
16+ await fetch ( `http://127.0.0.1:${ this . address ( ) . port } /` ) ;
17+ } catch {
18+ // ignore
19+ }
20+ process . exit ( 0 ) ;
21+ } ) ;
22+ } else {
23+ const child = cp . spawn ( process . execPath , [ __filename , 'child' ] ) ;
24+
25+ child . on (
26+ 'close' ,
27+ common . mustCall ( ( exitCode , signal ) => {
28+ assert . strictEqual ( exitCode , 0 ) ;
29+ assert . strictEqual ( signal , null ) ;
30+ } ) ,
31+ ) ;
32+ }
You can’t perform that action at this time.
0 commit comments