angular-cli: [1.7.0] ng serve not properly killed on CTRL+C with yarn/npm

Versions

Angular CLI: 1.7.0
Node: 6.9.5
OS: linux x64
Angular: 5.2.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.0
@angular-devkit/build-optimizer: 0.3.1
@angular-devkit/core: 0.3.1
@angular-devkit/schematics: 0.3.1
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.0
@schematics/angular: 0.3.1
@schematics/package-update: 0.3.1
typescript: 2.5.3
webpack: 3.11.0

Repro steps

  • create project with ng new
  • run yarn start or npm start
  • hit ctrl-c

Observed behavior

the ng process is still running

Desired behavior

The ng process should be stopped. It is stopped with v1.6.8 but not with v1.7.0

Mention any other details that might be useful (optional)

It happens also with node 8, with yarn or npm. The version of those did not change: only switching between v1.6.8 and v1.7.0 exhibits the problem.

When running ng serve by hand, surprisingly hitting ctrl+c does not stop the ng process, but you have to hit ctrl+c again for it to happen!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 32
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

killall ng

Try ctrl + shift + c

If the above doesn’t work the following can be tried. Issue occurrence while running Angular-CLI: Sometimes the session doesn’t get killed even if the running local server is stopped. In such cases, use the following command to close the port.

lsof -n -i4TCP:4200 kill -9 <PID>

This works for me…

Yeah I saw that on a SO answer and tried several variations, including ctrl + Z, etc. This was never an issue prior to updating from Angular CLI 1.5 to 1.6.8. Regular 'ol ctrl + c would stop everything. Now it just drops back to a command prompt and leaves 2 processes running. One for ng and one for an sh ng ... that runs the actual webserver. It’s just aggravating. I ended up adding another command to my package.json called kill and set it to sudo lsof -t -i tcp:443 | xargs kill -s 9 (my app runs on SSL, sub 443 for whatever port you’re using). Still would be great to find a way to make this work like it used to.

@switch120 It should fix it without --aot as well.

To temporary workaround this issue you can remove line 382 from node_modules/@ngtools/webpack/src/angular_compiler_plugin.js. This line should have process.once('SIGINT', handleParentProcessExit);.