Skip to content

Commit abe252c

Browse files
committed
fix: LSP tool startup reliability, shutdown hangs, and refactor into focused files
1. Server won't restart after a crash. startLocked() checked h.cmd != nil to decide if the server was running, but h.cmd stays non-nil after the process dies. A crashed server could never be restarted — every subsequent call got "LSP server already running". Fixed by adding a processDone channel that tracks actual process liveness. 2. stopLocked() hangs forever. It called sendRequestLocked("shutdown") synchronously, which blocks on reading stdout. If the server was unresponsive or already dead, this blocked indefinitely — and so did cmd.Wait() after it. Fixed by running the shutdown handshake in a goroutine with a 5-second timeout, then killing the process via context cancellation. 3. Data race on the stderr buffer. os/exec writes to a bytes.Buffer from one goroutine while readNotifications reads and resets it from another. bytes.Buffer is not thread-safe. Fixed by introducing a mutex-protected lockedBuffer. Assisted-By: docker-agent
1 parent d871092 commit abe252c

7 files changed

Lines changed: 1577 additions & 1439 deletions

File tree

0 commit comments

Comments
 (0)