Skip to content

Commit

Permalink
fix(@angular/cli): shut down after first Ctrl+C received
Browse files Browse the repository at this point in the history
Fixes #9647
  • Loading branch information
devoto13 authored and hansl committed Feb 21, 2018
1 parent a20b314 commit 78d48be
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions packages/@ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,28 +507,24 @@ export class AngularCompilerPlugin implements Tapable {
forkOptions);

// Handle child process exit.
const handleChildProcessExit = () => {
this._killForkedTypeChecker();
const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
'Falling back to type checking on main thread.';
this._warnings.push(msg);
};
this._typeCheckerProcess.once('exit', handleChildProcessExit);
this._typeCheckerProcess.once('SIGINT', handleChildProcessExit);
this._typeCheckerProcess.once('uncaughtException', handleChildProcessExit);

// Handle parent process exit.
const handleParentProcessExit = () => this._killForkedTypeChecker();
process.once('exit', handleParentProcessExit);
process.once('SIGINT', handleParentProcessExit);
process.once('uncaughtException', handleParentProcessExit);
this._typeCheckerProcess.once('exit', (_, signal) => {
this._typeCheckerProcess = undefined;

// If process exited not because of SIGTERM (see _killForkedTypeChecker), than something
// went wrong and it should fallback to type checking on the main thread.
if (signal !== 'SIGTERM') {
this._forkTypeChecker = false;
const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
'Falling back to type checking on main thread.';
this._warnings.push(msg);
}
});
}

private _killForkedTypeChecker() {
if (this._typeCheckerProcess && this._typeCheckerProcess.pid) {
treeKill(this._typeCheckerProcess.pid, 'SIGTERM');
this._typeCheckerProcess = undefined;
this._forkTypeChecker = false;
}
}

Expand Down

0 comments on commit 78d48be

Please sign in to comment.