Open luxaritas opened 2 years ago
Worth noting that this also affects the task runner in general. ForkedProcessTaskRunner SIGTERMs its child processes when the current process receives SIGINT/SIGTERM/SIGHUP, but if one of those child processes is running run-script, the script being run won't be killed
It may be related to #11722
I have probably hit the same issue with run-command executor. I'm trying to move some yarn scripts to own targets to related projects.
I created target for running firebase emulators using firebase cli firebase emulators:start
. This starts few java -processes which are still running after terminating my target.
This is also an issue with run-commands
.
Ie. write an executor that spawns another nx run process. nx process runs a target defined with run-commands
, spawning a persistant node server, kill the child nx process and the node process spawned by the run-commands will be orphaned and still live.
Do you have any updates on this issue? I'm having a lot of problems with the port still being used when the command is killed with Ctrl
+ C
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
I don't have the time to re-do the repro right now (and stackblitz is no longer playing nicely with nx) - any chance someone else on this thread can put together an updated repro for the latest nx version?
@luxaritas I am not 100% sure what your stackblitz was doing before.... but.... something is definitely broken with this
Current Behavior
If runExecutor is called within a child process invoking the run-script executor, killing the child process (ie, before it has finished running) leaves the executed script running
Expected Behavior
The executed script should be signaled to exit
From my understanding, this is caused by run-script calling execSync - Node never cleans up child processes when it exists. Presumably,
exec
should be used instead, so that a handle to the child process can be retained, so that signal handlers installed on the current process can callkill
when the current process exists, similarly to how run-commands works in parallel mode (that said - this issue is also presumably present in run-commands serial mode, which also uses execsync).Steps to Reproduce
https://stackblitz.com/edit/node-k9o4py?file=main.js,proc.js - run
npm start
Failure Logs
Environment
(This is for the stackblitz environment used for this repro above)