Skip to content

Commit 1973981

Browse files
Mazyodclaude
andcommitted
fix: reject pending LSP requests when server closes unexpectedly
When an LSP server dies before responding, _read_stdout hits EOF and exits silently, leaving pending request Futures unresolved and callers (e.g. process.stop()'s send.shutdown()) hung forever. Caught by Zuban on Linux CI: pool.cleanup() hung the Tests workflow for 20 minutes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fb8b267 commit 1973981

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

lsp_types/process.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,17 @@ async def _read_stdout(self) -> None:
319319
return
320320
except Exception:
321321
logger.exception("Client - Error reading stdout")
322+
finally:
323+
# Server closed the connection (EOF, crash, or task cancel) — reject
324+
# any outstanding requests so callers don't await forever.
325+
for future in list(self._pending_requests.values()):
326+
if not future.done():
327+
future.set_exception(
328+
Error(
329+
types.ErrorCodes.InternalError,
330+
"LSP server closed connection before responding",
331+
)
332+
)
322333

323334
async def _read_stderr(self) -> None:
324335
"""Read and log messages from the server's stderr."""

0 commit comments

Comments
 (0)