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 {
489489
490490 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
491491 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+ } ) ;
494498
495499 const forkTsCheckerHooks = ForkTsCheckerWebpackPlugin . getCompilerHooks (
496500 this . compiler
@@ -515,6 +519,8 @@ class ForkTsCheckerWebpackPlugin {
515519 this . cancellationToken . cleanupCancellation ( ) ;
516520 }
517521
522+ // clean-up listeners
523+ this . service . removeAllListeners ( ) ;
518524 this . service . kill ( ) ;
519525 this . service = undefined ;
520526 this . serviceRpc = undefined ;
You can’t perform that action at this time.
0 commit comments