fix(win): tree-kill local PTYs so ports free on terminal stop - #10346
fix(win): tree-kill local PTYs so ports free on terminal stop#10346innocarpe wants to merge 6 commits into
Conversation
a5cce6f to
4b3b450
Compare
Sync update (
|
|
Warning Review limit reached
Next review available in: 24 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe change adds Windows workspace-port process-tree termination with retryable PID liveness checks and injectable delays. POSIX termination remains SIGTERM-based. PTY shutdown replaces descendant snapshots with asynchronous descendant sweeps and extends Windows cleanup to immediate shutdowns. Tests cover ownership checks, retry outcomes, shutdown coordination, and natural process exit. PTY launch handling removes default WSL and Windows environment fallbacks, simplifies session and PATH handling, and stops registering the startup echo probe. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 178c6a60-1c8c-4c5a-b610-fe2cf3cc7ed0
📒 Files selected for processing (8)
src/main/ports/workspace-port-ownership.test.tssrc/main/ports/workspace-port-ownership.tssrc/main/providers/local-pty-provider.test.tssrc/main/providers/local-pty-provider.tssrc/main/pty-descendant-termination.test.tssrc/main/pty-descendant-termination.tssrc/main/windows-process-tree-kill.test.tssrc/main/windows-process-tree-kill.ts
4b3b450 to
8d56dd0
Compare
Sync update (
|
274473f to
1ad4b84
Compare
1ad4b84 to
e8060f1
Compare
Sync update (
|
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 104cb2b8-f6f5-4f9a-b795-d5824ed83219
📒 Files selected for processing (6)
src/main/ports/workspace-port-ownership.test.tssrc/main/ports/workspace-port-ownership.tssrc/main/providers/local-pty-provider.test.tssrc/main/providers/local-pty-provider.tssrc/main/pty-descendant-termination.test.tssrc/main/pty-descendant-termination.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/pty-descendant-termination.test.ts
On Windows, ConPTY shell-only kill left npm/dev-server children listening, so switching projects could still serve the previous app on the same port. - taskkill /T /F via killWithDescendantSweep for every local PTY stop on Windows - Ports UI kill path also tree-kills on Windows - Keep POSIX agent-only descendant sweep; plain POSIX terminals unchanged Closes stablyai#10150 Related: overlaps Windows agent path of stablyai#10004 / stablyai#10100
terminateWindowsProcessTree is best-effort and always resolves so PTY teardown is never blocked. Ports UI needs a real outcome: after taskkill, probe liveness with process.kill(pid, 0) and return failure if the PID is still alive. Addresses CodeRabbit review on stablyai#10183.
EPERM from process.kill(pid, 0) means the process is still alive without signal rights; do not report Ports kill success in that case. Addresses CodeRabbit follow-up on stablyai#10183.
… rebase cleanup No code change. Re-opens the contribution for review after branch recovery.
…ession tests Preserve WorkspacePortScanOptions on scanWorkspacePortProbes and re-add the authorizing re-scan metadata tests dropped during conflict resolution, while keeping Windows tree-kill liveness probes for stablyai#10150.
e8060f1 to
e94e4a8
Compare
Sync update (
|
Summary
taskkill /T /Fon the ConPTY root before shell kill, sonpm run dev/ Vite children release listening ports.process.kill.nohupchildren survive.Fixes #10150.
Why
Closing a terminal (or switching projects) on Windows only stopped the shell process. Child servers reparented and kept the port, so Project B appeared to serve Project A’s site.
Relationship to #10004 / #10100
Shares the Windows
taskkill /Thelper andkillWithDescendantSweepbranch. This PR applies tree-kill to all local Windows PTYs (not only agent sessions) and the Ports kill path, which is what frees dev-server ports. #10100 can be closed as partially superseded once this lands, or restacked to keep agent-specific POSIX notes.Test plan
windows-process-tree-kill,pty-descendant-termination(incl. Windows sweep),workspace-port-ownership,local-pty-providertestspnpm typecheck:nodenpm run devin a worktree terminal → close tab → confirm port free / Project B binds cleanly; Ports UI Stop also frees portELI5
Closing a terminal on Windows left child processes (like npm/Vite) holding ports. Local PTY stop now tree-kills the process tree so ports free immediately.