-
-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple processes exiting with code 0 or SIGTERM produce a non-zero exit code #187
Comments
Seconding that this is still an issue. saw this manifest more consistently on linux than macos.
It may be some internal race condition? I saw this output a single time when trying all of this. Note the
|
I found @JasonGhent's example helpful as a starting point to explore, but ultimately a touch confusing (at least to me) since it is catching SIGTERM, and thus not allowing the child process respond to the command signal. I recommend anyone running into this double check their own signal handlers. If you are registering a SIGTERM, then your node process will defer to that handler. You can see the behavior exhibited this way: Based on the way the I believe what's happening, although I haven't verified, is that the child process's own error handler responds to the SIGTERM (and exits with 1) before the previous error handler (which exited with 0) finishes registering this as a successful (0) kill. Please let me know if an MR might be considered for this behavior or not. |
I'm also facing the same problem, any solution to fix this ? |
This is very frustrating as it means I can't use --kill-others in any reasonable way without making it erroneously think there is an error. |
I am having the same issue, a typical ExpressJS server setup and I have a handler for SIGTERM. |
yep, I think this is what I came here to report, anyone have a workaround? |
I guess putting this at the end of my test express app is sufficient in my case process.once('SIGTERM', () => process.exit(0)) |
Please remember to add the Perhaps Keen to hear the thoughts of y'all. |
Thanks for this. I see now that |
Although this would be a breaking change. I would definitely expect the exit code to be the one from the first process with The most prominent use case is killing a (web) server when the tests you wanted to run on it are done. |
I agree with you @Th3S4mur41 but I don't know how to get the result of the first script. I'm executing a script in jenkins pipeline
and this generates :
|
is ng serve exited in this case? |
Any solution? |
@yarinsa Many cases are covered by some combination of --kill-others, --success, and --kill-signal (which must be used with --kill-others or --kill-others-on-fail). @gustavohenke It would be nice to be able to exit concurrently with the exit code of the sequentially-first exiting process, whatever it is: "If any of command A, command B, or command C exits with $EXITCODE, kill-others and exit with $EXITCODE." That is, "race these commands, and if the first to finish succeeds, exit 0, but if it fails, exit with its exit code (1 could also probably work for most cases)." I don't think there's a way to cover that scenario currently; or at least, I couldn't figure out how to do it. What you can do is say, "if all of one or more particular commands succeed, then exit with 0, but if any command fails, exit with 1." |
4.1.0
This is my output. All the processes are exiting with 0 or SIGTERM. But the final exit code is non-zero.
Here are my npm scripts:
test:functional:docker:ra
runs the same commands but exits with 0 (the desired output).I need this exit code for my build pipeline.
The text was updated successfully, but these errors were encountered: