open-cli-tools / open-cli-tools/concurrently
Processes not terminating correctly (or at all?)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.9k
- Forks
- 281
- Avg merge
- 17h 12m
- Merged PRs (30d)
- 1
Description
I've started using concurrently quite heavily.
For example, I might have tsc, webpack and node-sass all running with --watch during development.
I started noticing weird behavior, including on several occasions, my source files randomly getting deleted when I run git commands! Fortunately these are usually under source-control, so I can get them back with a git reset, but it's quite confusing.
The problem, it seems, is when I try to shut down concurrently, I can sometimes wait for several minutes and nothing happens - often this happens after e.g. webpack has crashed or stalled, which is tends to do if I remove one of the source-files it's watching.
So eventually I press CTRL+C again, which terminates concurrently, but appears to leave running processes hanging in the background.
Here's some terminal output:
$ ps -a
PID TTY TIME CMD
1541 tty1 00:00:00 node
1685 tty1 00:00:26 node-sass
1723 tty1 00:00:00 node
1867 tty1 00:00:06 node-sass
5220 tty2 00:00:00 sudo
5221 tty2 00:00:03 caddy
5504 tty1 00:00:00 node
5648 tty1 00:02:16 node-sass
6041 tty1 00:00:00 ps
$ kill 1685
$ ps -a
PID TTY TIME CMD
1541 tty1 00:00:00 node
1685 tty1 00:00:26 node-sass
1723 tty1 00:00:00 node
1867 tty1 00:00:06 node-sass
5220 tty2 00:00:00 sudo
5221 tty2 00:00:03 caddy
5504 tty1 00:00:00 node
5648 tty1 00:02:16 node-sass
6042 tty1 00:00:00 ps
$ kill -9 1685
$ [1] npm run watch-sass exited with code null
^C
$ ps -a
PID TTY TIME CMD
1723 tty1 00:00:00 node
1867 tty1 00:00:06 node-sass
5220 tty2 00:00:00 sudo
5221 tty2 00:00:03 caddy
5504 tty1 00:00:00 node
5648 tty1 00:02:16 node-sass
6043 tty1 00:00:00 ps
As you can see, my first attempt to kill 1685 fails - I'm betting this is why concurrently hangs as well, it isn't able to shut down the hanging node-sass process the normal way.
Forcing node-sass to stop with kill -9 1685 also apparently causes the hanging node process (which is running concurrently) to report that node-sass has finally stopped - and as you can see from the last ps -a, both the node process that was running concurrently, and the node-sass process it was running, have finally stopped.
Is it possible to set a timeout for concurrently, e.g. forcing child processes to stop after a set maximum period of waiting? I didn't see a command-line option for that.
Any idea how to resolve this?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the shutdown behavior with the watch commands described in the issue, then trace how concurrently handles CTRL+C and child-process termination. Done means a documented or implemented timeout behavior that stops hanging child processes and leaves no background processes after shutdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100