You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
git bash.exe processes on Windows get orphaned #5525
This is the same underlying issue as #3057 but Windows-specific. The process cleanup code has inconsistent implementations:
Shell cleanup (shell/shell.ts) — Robust
process.kill(-pid,"SIGTERM")// Kill process groupawaitBun.sleep(200)if(!opts?.exited?.()){process.kill(-pid,"SIGKILL")// Escalate if still alive}
LSP cleanup (lsp/client.ts) — Weak
input.server.process.kill()// Just SIGTERM, no group, no escalation
Why orphans happen
No process group kill (-pid) — Child processes spawned by the parent (e.g., tsserver from typescript-language-server, or subshells from bash.exe) are not targeted
No SIGKILL escalation — If SIGTERM is ignored, the process survives
No exit confirmation — Code assumes .kill() works but never verifies
Windows-specific note
On Windows, the shell module has a fallback path using taskkill:
@rekram1-node You're right that the user-reported symptom (scripts running after Ctrl+C) is specifically about the bash tool - that's a separate abort race condition where void kill() is fire-and-forget.
However, the LSP fix addresses a different scenario I encountered: when using git worktrees with parallel subagents, each worktree spawns its own set of LSPs. After the session ends, orphaned tsserver processes remained because:
LSP servers weren't spawned with detached: true (needed for process group kill)
shutdown() used plain process.kill() instead of Shell.killTree()
So the LSP PR (#5875) addresses LSP cleanup on session disposal, while the bash issue (#3057) is about abort during execution. They're related but different code paths.
Happy to close the LSP PR if you don't think it's needed though!
Okay cool, yeah these days if I read a big AI diagnosis I really need to be careful because most of the time it's slop, you're response here sounds a lot more sane hahaa so thank you!
Activity
github-actions commentedon Dec 14, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
anntnzrb commentedon Dec 21, 2025
Root cause analysis
This is the same underlying issue as #3057 but Windows-specific. The process cleanup code has inconsistent implementations:
Shell cleanup (
shell/shell.ts) — RobustLSP cleanup (
lsp/client.ts) — WeakWhy orphans happen
-pid) — Child processes spawned by the parent (e.g.,tsserverfromtypescript-language-server, or subshells frombash.exe) are not targeted.kill()works but never verifiesWindows-specific note
On Windows, the shell module has a fallback path using
taskkill:The
/tflag kills the process tree. This pattern should also be applied to LSP cleanup on Windows.Related: #3057 (general process cleanup discussion with suggested fix)
anntnzrb commentedon Dec 21, 2025
Opened PRs to address this:
Shell.killTree()+detached: true)killPtyTree()withtaskkill /ton Windows)Both now properly kill process trees on Windows using
taskkill /pid <pid> /f /t.rekram1-node commentedon Dec 21, 2025
@anntnzrb I dont think the lsps are having an orphan issue? I think it’s just the bash tool
anntnzrb commentedon Dec 21, 2025
@rekram1-node You're right that the user-reported symptom (scripts running after Ctrl+C) is specifically about the bash tool - that's a separate abort race condition where
void kill()is fire-and-forget.However, the LSP fix addresses a different scenario I encountered: when using git worktrees with parallel subagents, each worktree spawns its own set of LSPs. After the session ends, orphaned
tsserverprocesses remained because:detached: true(needed for process group kill)shutdown()used plainprocess.kill()instead ofShell.killTree()So the LSP PR (#5875) addresses LSP cleanup on session disposal, while the bash issue (#3057) is about abort during execution. They're related but different code paths.
Happy to close the LSP PR if you don't think it's needed though!
rekram1-node commentedon Dec 21, 2025
maybe im misunderstanding but Because we dont spawn lsps with detached true i dont think we need special kill logic
or am i misunderstanding u?
Ur diagnosis seemed ai generated so im trying to make sure we are both actually understanding source of issue instead of relying on its response
anntnzrb commentedon Dec 21, 2025
Fair point - let me clarify with a concrete example of what I observed:
typescript-language-serverwhich spawnstsserveras a childps aux | grep tsserverand saw 7+ orphanedtsserverprocesses still runningThe current
shutdown()callsprocess.kill()which sends SIGTERM totypescript-language-server, but its childtsserversurvives because:detached: true, the child isn't in a killable process groupShell.killTree(), there's no SIGKILL escalation if SIGTERM is ignoredMy PR adds both:
detached: truewhen spawning → makes the process a group leaderShell.killTree()on shutdown → kills the group with-pidand escalates to SIGKILLYou're right that without
detached: true, the group kill won't work - that's why the PR adds both together.rekram1-node commentedon Dec 21, 2025
Okay cool, yeah these days if I read a big AI diagnosis I really need to be careful because most of the time it's slop, you're response here sounds a lot more sane hahaa so thank you!
I'll take a look at those