-
Notifications
You must be signed in to change notification settings - Fork 57
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
How to better kill the nested process tree of spawned processes? #2371
Comments
Hi @bahmutov, Thanks for reaching out on this. The behavior you are describing is the current behavior (although the red color should probably be updated to yellow instead):
Please note that the lingering processes logic needs some serious improvements, which are outlined in https://github.com/netlify/pod-workflow/issues/74. It is possible that those improvements might at least partially solve some of the problems you are describing. Please also note that terminating a process tree is not as trivial as it first sounds. This is the second most requested feature in Execa. We tried implementing twice, but both PRs did not complete. The main problem is for the build system to be able to distinguish programmatically between the two following cases:
One question I am wondering is: wouldn't the problem above still be a problem when Cypress is run locally (without Netlify)? Namely, would the |
Note: this problem was reported here as well. |
I agree, there is no good option and this concerns the other Linux CIs - they just don't panic and shut down the container :) |
At the moment, the build in Netlify is not panicking. Currently, the only impact of lingering processes is the presence of this warning message in the build logs. We might be sending the wrong message with the poor choice of the red color instead of yellow though. Netlify is not waiting for those processes to end: the container is shut down right away. Another improvement we could do would be to ignore specific programs which are known to fall in the (cc @mheffner who was involved in earlier discussions about this topic) |
While not the best way to handle this, I did write an experimental build plugin to handle this: https://github.com/mheffner/netlify-plugin-process-cleanup However, we should likely kill those in the netlify build framework. |
@mheffner From https://github.com/netlify/buildbot/issues/984, it appears that we currently terminate lingering processes. However, this is done as part of terminating the container it seems (so terminating it inside I was curious about your thoughts on the warning message? Is this something we still intend to print? (Also tagging @fool who was part of the above issue) |
@ehmicky Yeah, we don't currently terminate them in the build. IMO we should terminate all of them before proceeding to the upload phase as it can cause inconsistent behavior if something is still modifying files while uploading. I think we should still print the warning, even if in the future we kill them before proceeding in the build process. If a user unintentionally left something running, it could be the source of a inconsistent deploy and the message would be helpful for debugging. We would change color though if we thought red was too much. I would also consider excluding some known repeat offenders (looking at you gatsby telemetry) from the list if we find them running. If we know they are harmless we don't need to alert users as loudly IMO. |
You're right, thanks for correcting (I implied the opposite in my previous comment, but this was incorrect). I agree we should be explicit about terminating those. I mentioned above about some of the potential problems in using process trees to figure out which processes to terminate. For example, when the tree is deep and some intermediary process exits, their children would be inherited by the However, we might have a solution: comparing the flat list of processes before/after the build command/plugins, and terminating any new processes. This approach is outlined in this issue and is easier to implement now that the logic is in
💯
👍 Going back to your original problem @bahmutov, would the following course of action help with Cypress?
|
I say yellow color is a good step :) |
Hi @bahmutov, We've just released some improvements to this warning message which should make it clearer. The color is now yellow and the message has been improved. Also the detection itself has been improved. We've also added a support guide in Netlify Community to explain why this message appears and how to remove it. We make sure that any lingering processes are terminated at the end of the build, as you suggested in your initial comment. However, when we do, we print that warning message because it might indicate an error that users might want to fix. For example, they might spawn a process and forget to This gets a little clumsy when that behavior is performed by a widely used library (such as Please let me know what you think about that approach. |
This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 14 days if no further activity occurs. Thanks! |
This issue was closed because it had no activity for over 1 year. |
Which problem is this feature request solving?
Our users have noticed that nested backend child processes are not killed when running Cypress end-to-end tests during the build steps. For example, if we start a backend server using
npm run develop
which starts thegatsby develop
process then only the top-level child process is killed (because utils.run is just execa.run which does childProcess.kill via https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal which does not kill "grand" children.Describe the solution you'd like
It would be nice to kill somehow the entire process tree
Describe alternatives you've considered
Netlify build just shuts down everything, maybe warning about these orphan processes, but does not show it as a dangerous error
Can you submit a pull request?
No.
The text was updated successfully, but these errors were encountered: