File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -489,8 +489,12 @@ class ForkTsCheckerWebpackPlugin {
489
489
490
490
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
491
491
this . serviceRpc = new RpcProvider ( message => this . service ! . send ( message ) ) ;
492
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
493
- this . service . on ( 'message' , message => this . serviceRpc ! . dispatch ( message ) ) ;
492
+ this . service . on ( 'message' , message => {
493
+ if ( this . serviceRpc ) {
494
+ // ensure that serviceRpc is defined to avoid race-conditions
495
+ this . serviceRpc . dispatch ( message ) ;
496
+ }
497
+ } ) ;
494
498
495
499
const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin . getCompilerHooks (
496
500
this . compiler
@@ -515,6 +519,8 @@ class ForkTsCheckerWebpackPlugin {
515
519
this . cancellationToken . cleanupCancellation ( ) ;
516
520
}
517
521
522
+ // clean-up listeners
523
+ this . service . removeAllListeners ( ) ;
518
524
this . service . kill ( ) ;
519
525
this . service = undefined ;
520
526
this . serviceRpc = undefined ;
You can’t perform that action at this time.
0 commit comments