Skip to content

Commit c5ec36e

Browse files
devoto13hansl
authored andcommitted
fix(@angular/cli): shut down after first Ctrl+C received
Fixes #9647
1 parent bbcc581 commit c5ec36e

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

packages/@ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -504,28 +504,24 @@ export class AngularCompilerPlugin implements Tapable {
504504
forkOptions);
505505

506506
// Handle child process exit.
507-
const handleChildProcessExit = () => {
508-
this._killForkedTypeChecker();
509-
const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
510-
'Falling back to type checking on main thread.';
511-
this._warnings.push(msg);
512-
};
513-
this._typeCheckerProcess.once('exit', handleChildProcessExit);
514-
this._typeCheckerProcess.once('SIGINT', handleChildProcessExit);
515-
this._typeCheckerProcess.once('uncaughtException', handleChildProcessExit);
516-
517-
// Handle parent process exit.
518-
const handleParentProcessExit = () => this._killForkedTypeChecker();
519-
process.once('exit', handleParentProcessExit);
520-
process.once('SIGINT', handleParentProcessExit);
521-
process.once('uncaughtException', handleParentProcessExit);
507+
this._typeCheckerProcess.once('exit', (_, signal) => {
508+
this._typeCheckerProcess = undefined;
509+
510+
// If process exited not because of SIGTERM (see _killForkedTypeChecker), than something
511+
// went wrong and it should fallback to type checking on the main thread.
512+
if (signal !== 'SIGTERM') {
513+
this._forkTypeChecker = false;
514+
const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
515+
'Falling back to type checking on main thread.';
516+
this._warnings.push(msg);
517+
}
518+
});
522519
}
523520

524521
private _killForkedTypeChecker() {
525522
if (this._typeCheckerProcess && this._typeCheckerProcess.pid) {
526523
treeKill(this._typeCheckerProcess.pid, 'SIGTERM');
527524
this._typeCheckerProcess = undefined;
528-
this._forkTypeChecker = false;
529525
}
530526
}
531527

0 commit comments

Comments
 (0)