@@ -507,28 +507,24 @@ export class AngularCompilerPlugin implements Tapable {
507507 forkOptions ) ;
508508
509509 // Handle child process exit.
510- const handleChildProcessExit = ( ) => {
511- this . _killForkedTypeChecker ( ) ;
512- const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
513- 'Falling back to type checking on main thread.' ;
514- this . _warnings . push ( msg ) ;
515- } ;
516- this . _typeCheckerProcess . once ( 'exit' , handleChildProcessExit ) ;
517- this . _typeCheckerProcess . once ( 'SIGINT' , handleChildProcessExit ) ;
518- this . _typeCheckerProcess . once ( 'uncaughtException' , handleChildProcessExit ) ;
519-
520- // Handle parent process exit.
521- const handleParentProcessExit = ( ) => this . _killForkedTypeChecker ( ) ;
522- process . once ( 'exit' , handleParentProcessExit ) ;
523- process . once ( 'SIGINT' , handleParentProcessExit ) ;
524- process . once ( 'uncaughtException' , handleParentProcessExit ) ;
510+ this . _typeCheckerProcess . once ( 'exit' , ( _ , signal ) => {
511+ this . _typeCheckerProcess = undefined ;
512+
513+ // If process exited not because of SIGTERM (see _killForkedTypeChecker), than something
514+ // went wrong and it should fallback to type checking on the main thread.
515+ if ( signal !== 'SIGTERM' ) {
516+ this . _forkTypeChecker = false ;
517+ const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
518+ 'Falling back to type checking on main thread.' ;
519+ this . _warnings . push ( msg ) ;
520+ }
521+ } ) ;
525522 }
526523
527524 private _killForkedTypeChecker ( ) {
528525 if ( this . _typeCheckerProcess && this . _typeCheckerProcess . pid ) {
529526 treeKill ( this . _typeCheckerProcess . pid , 'SIGTERM' ) ;
530527 this . _typeCheckerProcess = undefined ;
531- this . _forkTypeChecker = false ;
532528 }
533529 }
534530
0 commit comments