nanocoder
nanocoder copied to clipboard
[Bug] On Windows an LSP server started through a .cmd shim keeps running after the client is stopped
Description
On Windows, npm-installed language servers start through a .cmd shim, so child.kill() only ends cmd.exe. A server that ignores the LSP exit request (or is stuck) keeps running after LSPClient.stop().
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at eb7dee57)
- Provider: Not provider-specific
- Model: Not model-specific
Steps to Reproduce
- Create a
.cmdshim that runs a node script. The script answersinitializeandshutdown, ignoresexitand stdin end, stays alive, and writes its pid to a file. const client = new LSPClient({name: 'hung-server', command: '<shim>.cmd', args: ['--stdio'], languages: ['ts']}), thenawait client.start()andawait client.stop().- Wait 1.5 seconds and check whether the pid from the file is still running.
Expected Behavior
The server process is gone after stop().
Actual Behavior
The pid is still running.
Logs/Screenshots
server pid 22436 is still running after stop()
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder (main)
Suggested fix:
source/lsp/lsp-client.ts:179(this.process.kill()instop()) and:148(child.kill()after a failed start): usesignalProcessTree(child)fromsource/utils/process-tree.ts, which already runstaskkill /T /Fon Windows.- Add a Windows-only test like the steps above.
Related: PR #1699 (the same fix for execute_bash).
I'd like to pick this up. I'm on Windows 11, so I can reproduce it with a .cmd shim. Plan: use signalProcessTree in stop() and in the failed-start path of LSPClient, and add a Windows-only test that checks the server pid is gone after stop().