From c5ec36e094d274aaa30204d7929d06ffefa12870 Mon Sep 17 00:00:00 2001 From: Yaroslav Admin Date: Wed, 21 Feb 2018 16:14:53 +0100 Subject: [PATCH] fix(@angular/cli): shut down after first Ctrl+C received Fixes #9647 --- .../webpack/src/angular_compiler_plugin.ts | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/@ngtools/webpack/src/angular_compiler_plugin.ts b/packages/@ngtools/webpack/src/angular_compiler_plugin.ts index 8097e2e516d7..0c56e195602a 100644 --- a/packages/@ngtools/webpack/src/angular_compiler_plugin.ts +++ b/packages/@ngtools/webpack/src/angular_compiler_plugin.ts @@ -504,28 +504,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; } }