fix(hub): kill the whole child-process tree on Windows - #404
Closed
zahidzorbaz wants to merge 1 commit into
Closed
zahidzorbaz wants to merge 1 commit into
zahidzorbaz wants to merge 1 commit into
Conversation
On Windows, tinyexec runs `.cmd` shims (e.g. `node_modules/.bin/vitest.cmd`) through `cmd.exe`, so `terminate()`, `restart()` and stream cancel only killed the wrapper and left the real program running and holding its ports. Kill the tree with `taskkill /T /F` there, wait for it before `restart()` spawns the next run, and keep reporting host-initiated kills as `stopped` with an `undefined` exit code on every platform. Fixes devframes#402 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
◈ PR Lens
Architecture 1 component touched across 2 lanes. Play the interactive walkthrough Data flow
Follow each request, response and payload View
Tip Push a commit and the comment redraws for the new head. A slow older run never overwrites a newer one 🪧 More tips
Thanks for using PR Lens! It's built by Coldtea, free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This branch was previously deployed
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.
Description
On Windows, stopping a
startChildProcess()session left the real program running. tinyexec runs anything that isn't a.exe/.com(including thenode_modules/.bin/*.cmdshims) throughcmd.exe /d /s /c, so the pid the host holds is the wrapper's.cp.kill()ends only that process, and Windows doesn't kill descendants, so e.g.vitest --uikept running and kept its port.This PR:
killProcessTree()inhost-terminals.ts: on Windows, while the run is alive, it runstaskkill /pid <pid> /T /Fand falls back tocp.kill()iftaskkillfails; elsewhere it iscp.kill()as before.terminate(),restart()and the stream'scancel().restart()now waits for the old tree to exit before spawning the next run, so the new run can take the same ports.taskkill /Fends the process with exit code 1 instead of a signal, so runs killed by the host are tracked and reportstatus: 'stopped',exitCode: undefinedandkilled: true, as they already did on POSIX. TheDevframeChildProcessOutputdoc comment is updated to match.POSIX behaviour is unchanged. The PTY path (
startPtySession) and@devframes/plugin-terminalsare not touched.Linked Issues
Fixes #402
Additional context
describe.runIf(process.platform === 'win32')block inhost-terminals.test.tsstarts a real.cmdshim that launches node, and checks thatterminate(),restart()and stream cancel (viahost.remove()) kill the node grandchild, and thatterminate()reports stopped/killed with anundefinedexit code. All 4 tests fail onmainand pass with this change on Windows 11. They are skipped on Linux/macOS CI, since thecmd.exewrapping only happens on Windows.pnpm lint,pnpm knipandpnpm typecheckpass.pnpm testpasses excepttests/exports.test.ts > devframe > dts: ./internal, a snapshot export-order mismatch (importAgenticMcp) that also fails on a cleanmainhere and is unrelated to this change.🤖 Generated with Claude Code