Skip to content

Commit 0b88f7f

Browse files
committed
fix(@angular/cli): shut down after first Ctrl+C received
Fixes #9647
1 parent 3be17e7 commit 0b88f7f

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
"style-loader": "^0.19.1",
9292
"stylus": "^0.54.5",
9393
"stylus-loader": "^3.0.1",
94-
"tree-kill": "^1.0.0",
9594
"typescript": "~2.6.2",
9695
"uglifyjs-webpack-plugin": "^1.1.8",
9796
"url-loader": "^0.6.2",
@@ -142,6 +141,7 @@
142141
"tar": "^4.1.1",
143142
"temp": "0.8.3",
144143
"through": "^2.3.6",
144+
"tree-kill": "^1.0.0",
145145
"ts-node": "^4.1.0",
146146
"tslint": "^5.8.0",
147147
"zone.js": "^0.8.20"

packages/@ngtools/webpack/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"npm": ">= 3.0.0"
2626
},
2727
"dependencies": {
28-
"tree-kill": "^1.0.0",
2928
"chalk": "~2.2.0",
3029
"loader-utils": "^1.0.2",
3130
"enhanced-resolve": "^3.1.0",

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

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as path from 'path';
55
import * as ts from 'typescript';
66

77
const ContextElementDependency = require('webpack/lib/dependencies/ContextElementDependency');
8-
const treeKill = require('tree-kill');
98

109
import { WebpackResourceLoader } from './resource_loader';
1110
import { WebpackCompilerHost } from './compiler_host';
@@ -507,28 +506,24 @@ export class AngularCompilerPlugin implements Tapable {
507506
forkOptions);
508507

509508
// 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);
509+
this._typeCheckerProcess.once('exit', (_, signal) => {
510+
this._typeCheckerProcess = undefined;
511+
512+
// If process exited not because of SIGTERM (see _killForkedTypeChecker), than something
513+
// went wrong and it should fallback to type checking on the main thread.
514+
if (signal !== 'SIGTERM') {
515+
this._forkTypeChecker = false;
516+
const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
517+
'Falling back to type checking on main thread.';
518+
this._warnings.push(msg);
519+
}
520+
});
525521
}
526522

527523
private _killForkedTypeChecker() {
528-
if (this._typeCheckerProcess && this._typeCheckerProcess.pid) {
529-
treeKill(this._typeCheckerProcess.pid, 'SIGTERM');
524+
if (this._typeCheckerProcess) {
525+
this._typeCheckerProcess.kill('SIGTERM');
530526
this._typeCheckerProcess = undefined;
531-
this._forkTypeChecker = false;
532527
}
533528
}
534529

0 commit comments

Comments
 (0)