cli: Kill the serve-web process tree on idle timeout - #333719
Open
Kie (Kidsunbo) wants to merge 1 commit into
Open
cli: Kill the serve-web process tree on idle timeout#333719Kie (Kidsunbo) wants to merge 1 commit into
Kie (Kidsunbo) wants to merge 1 commit into
Conversation
Author
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates serve-web idle-timeout shutdown to reduce orphaned server processes.
Changes:
- Uses
kill_treefor process-tree termination. - Waits five seconds before attempting a forced kill.
Suppressed comments (1)
cli/src/commands/serve_web.rs:947
kill_treeonly sends SIGTERM, but this timeout waits for the launcher alone. If the shell exits while a descendant ignores or hangs on SIGTERM,child.wait()succeeds immediately and the forced-kill path is skipped; even on timeout,child.kill()targets only the launcher. The shutdown can therefore still leaveserver-main.jsrunning. The fallback needs to force-kill the captured process tree/process group (and verify descendants exit), not just the direct child.
if tokio::time::timeout(REAP_TIMEOUT, child.wait()).await.is_err() {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
cli/src/commands/serve_web.rs:947
- The timeout only waits for the launcher, not the descendants that
kill_treesignaled. Because the shell can exit immediately whileserver-main.jsis still shutting down or ignores SIGTERM,child.wait()can succeed before the five seconds elapse; the fallback is then skipped. Even when the timeout does fire,child.kill()force-kills only that launcher, recreating the orphan scenario this change is intended to prevent. The graceful tree operation needs to retain/observe the descendant set and force-kill the whole tree after the grace period, rather than keying escalation solely on the launcher's exit.
if tokio::time::timeout(REAP_TIMEOUT, child.wait()).await.is_err() {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #332764
serve-webpreviously killed only the direct launcher process when reachingthe idle timeout, potentially leaving the Node.js server and its descendants
running.
Use
kill_treeto terminate the complete process tree, wait for the launcherto exit, and fall back to a forced kill after a timeout.