cli: Kill the serve-web process tree on idle timeout - #333719
cli: Kill the serve-web process tree on idle timeout#333719Kie (Kidsunbo) wants to merge 1 commit into
Conversation
@microsoft-github-policy-service agree |
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.
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() {
0cae804 to
6af4cfa
Compare
18c4b6f to
ea10c66
Compare
|
Connor Peet (@connor4312) Hi, could you please take a look at this PR? It fixes a process leak that can consume all available memory and cause performance issues or crashes. This issue has been affecting me for some time, so I’d greatly appreciate a review when you have a chance. Thanks! |
ea10c66 to
d2e0ae6
Compare
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.