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
Remove process.exit(1) from babel-node #9758
Remove process.exit(1) from babel-node #9758
Conversation
Because it breaked graceful shutdown of the sub process.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10596/ |
1 similar comment
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10596/ |
This makes sense 👍I'm still worried about the functionality here because I don't think this change fixes #8526 where the |
Probably yes, but I'm not an expert on this topic.
|
I'm not exactly sure what would happen if the I think the initial SIGINT from the Ctrl-C should be plenty to alert the child that it should die, and the parent re-sending the signal (2.i in @nicolo-ribaudo's chart) does not make sense and should be removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this PR is ok as-is.
I did some experiments around processes management at https://gist.github.com/nicolo-ribaudo/e6dd1806e184aea49a824d1dea2d0001, which simluates what this PR does.
You can run node main.js
and kill one of the processes by running kill -SIGINT 12345
(replace 12345
with the correct PID).
If I kill the child process (which is what running Ctrl+C
in @babel/node
does), I get this output:
Main process is pid 23024
Child process is pid 23031
Child process killed
Child process is exiting...
Child process exited. code: 0, signal: null
Main process is exiting...
If I kill the main process, I get this output:
Main process is pid 23183
Child process is pid 23190
Main process killed
Killing child process...
Child process killed
Child process is exiting...
Child process exited. code: 0, signal: null
Main process is exiting...
As you can see, the child process doesn't receive SIGINT
twice (so this PR also fixes #8526).
You can change EXITCODE
in child.js
to check that the exit code of the child process is not changed by. the main process.
If you comment lines 24-25
of main.js
(#9758 (comment)) and kill the main process, the child process will stay alive. On the other hand, even with those lines the child process won't receive SIGINT
twice (#8526).
@nicolo-ribaudo Thanks for doing that testing! It looks like this kills two birds with one stone. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Because it breaked graceful shutdown of the sub process.
Because it breaked graceful shutdown of the sub process. For example, if you have an express server, catch the SIGINT signal and process.exit(0) after closing the server, the command would always return exit code 1. This PR allows the subprocess to decide how to exit itself.