Open LonguCodes opened 1 year ago
Found the potentially incorrect lines https://github.com/nrwl/nx/blob/21d3c5e63c2e41b1f414d01194fbdb274a3185b2/packages/nx/src/tasks-runner/forked-process-task-runner.ts#L480-L506
My plugin for firebase has experienced this issue for a while now; the firebase emulation suite is not terminating cleanly when invoked using nx:run-command
.
The firebase cli emulator command is a long running task and the problem is that the firebase cli tool does not receive a SIGINT
for a ctrl+c exit so it does not exit cleanly.
In the above code referenced by @LonguCodes , my specific problem is fixed by simply not calling process.exit()
in the SIGINT
handler.
Questions:
SIGINT
handler kill with SIGTERM
instead?process.exit()
in SIGINT
? (since not doing that for SIGKILL
SIGTERM
)@simondotm If you do not use process.exit()
in the handler of SIGINT
or SIGTERM
, the process will not shut down. This would mean that we would kill every child process, but not the main one.
SIGKILL
is uncatchable, so you are not able to do process.on('SIGKILL')
I think you meant SIGTERM
, not SIGKILL
. Not sure about the answer, will comment when I find out
Sorry yes, I meant SIGTERM
in question 2
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! 🙏
👀
Since updating from Nx 16 to Nx 17 I see different behaviour from CTRL+C now, tasks spawned via nx CLI seem to be aggressively killed and I see:
ELIFECYCLE Command failed with exit code 128.
This happens in Nx 18 for me also.
And now my previous workaround of creating a custom serve executor that spawned its own processes and handled exit signals itself to ensure my spawned processes would receive a SIGINT, no longer works - presumably because the top level process is nx serve
and my executor is a child process of that.
I see the forked-process-task-runner.js
module has changed quite a bit since I last looked at it, but I've not looked any further into the code to understand if/why child processes are not getting the exit signals they need.
This is really unhelpful for my plugin as the Firebase emulator really needs to receive that exit event to shut itself down gracefully.
Linking to #13766 for reference
This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏
Current Behavior
When running any command and sending a signal to it,
.bin/nx
sends different signals to the underlying process (run-executor
) depending on the source of the signalIf using
CTRL+C
to sendSIGINT
signal, both the main process and the underlying process receiveSIGINT
(not sure why)If using
kill -s INT <pid of the main process>
, the main process getsSIGINT
, but the child process (run-executor
) getsSIGTERM
This manifests in the underlying application receiving incorrect signals and/or
@nx/js:node
not passing the signal to the app processExpected Behavior
In both situations,
SIGINT
should be received by therun-executor
processGitHub Repo
No response
Steps to Reproduce
to the compiled nx library in
node_modules/nx/bin/run-executor.js
kill -s INT <pid>
Nx Report
Failure Logs
No response
Operating System
Additional Information
After discussion, I'm willing to create a PR to fix mentioned issue