docs(lsp): clarify drainStderr cancellation relies on pipe EOF

The goroutine parks in the blocking stderr.Read, so closing c.done does not interrupt it; termination relies on the read erroring at pipe EOF when the process is killed. The c.done select is only a best-effort fast path.
This commit is contained in:
2026-06-20 00:33:32 +01:00
parent 5ed14457f1
commit b6489ee4bc
+6
View File
@@ -121,6 +121,12 @@ func NewClient(cmd *exec.Cmd) (*Client, error) {
// drainStderr consumes stderr output to prevent the LSP server from blocking.
// LSP servers may write diagnostic messages to stderr which we discard.
//
// Cancellation note: the goroutine parks in the blocking stderr.Read below, so
// closing c.done does not interrupt it directly — termination relies on the
// read returning an error when the pipe reaches EOF (the process is killed on
// Close). The c.done check is only a best-effort fast path for the case where
// done is already closed between reads.
func (c *Client) drainStderr() {
buf := make([]byte, StderrBufferSize)
for {