@@ -60,6 +60,7 @@ export class ForkedProcessTaskRunner {
60
60
this . processes . add ( p ) ;
61
61
62
62
p . once ( 'exit' , ( code , signal ) => {
63
+ this . processes . delete ( p ) ;
63
64
if ( code === null ) code = this . signalToCode ( signal ) ;
64
65
if ( code !== 0 ) {
65
66
const results : BatchResults = { } ;
@@ -171,6 +172,7 @@ export class ForkedProcessTaskRunner {
171
172
} ) ;
172
173
173
174
p . on ( 'exit' , ( code , signal ) => {
175
+ this . processes . delete ( p ) ;
174
176
if ( code === null ) code = this . signalToCode ( signal ) ;
175
177
// we didn't print any output as we were running the command
176
178
// print all the collected output|
@@ -407,28 +409,36 @@ export class ForkedProcessTaskRunner {
407
409
// When the nx process gets a message, it will be sent into the task's process
408
410
process . on ( 'message' , ( message : Serializable ) => {
409
411
this . processes . forEach ( ( p ) => {
410
- p . send ( message ) ;
412
+ if ( p . connected ) {
413
+ p . send ( message ) ;
414
+ }
411
415
} ) ;
412
416
} ) ;
413
417
414
418
// Terminate any task processes on exit
415
419
process . on ( 'SIGINT' , ( ) => {
416
420
this . processes . forEach ( ( p ) => {
417
- p . kill ( 'SIGTERM' ) ;
421
+ if ( p . connected ) {
422
+ p . kill ( 'SIGTERM' ) ;
423
+ }
418
424
} ) ;
419
425
// we exit here because we don't need to write anything to cache.
420
426
process . exit ( ) ;
421
427
} ) ;
422
428
process . on ( 'SIGTERM' , ( ) => {
423
429
this . processes . forEach ( ( p ) => {
424
- p . kill ( 'SIGTERM' ) ;
430
+ if ( p . connected ) {
431
+ p . kill ( 'SIGTERM' ) ;
432
+ }
425
433
} ) ;
426
434
// no exit here because we expect child processes to terminate which
427
435
// will store results to the cache and will terminate this process
428
436
} ) ;
429
437
process . on ( 'SIGHUP' , ( ) => {
430
438
this . processes . forEach ( ( p ) => {
431
- p . kill ( 'SIGTERM' ) ;
439
+ if ( p . connected ) {
440
+ p . kill ( 'SIGTERM' ) ;
441
+ }
432
442
} ) ;
433
443
// no exit here because we expect child processes to terminate which
434
444
// will store results to the cache and will terminate this process
0 commit comments