From 404bd1418dd12530d4d4be5b6669e24c8ba29883 Mon Sep 17 00:00:00 2001 From: Henrik Jess Nielsen Date: Sun, 10 May 2026 15:13:03 +0200 Subject: [PATCH] fix: add 3s timeout to LSP backend connection (handles CI firewall drops) asyncio.open_connection hangs indefinitely when backend port is silently dropped. Add wait_for(timeout=3.0) so the WS close frame is always sent within the test's 5s window. --- ilsp/server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ilsp/server.py b/ilsp/server.py index f1bee87..8e724d2 100644 --- a/ilsp/server.py +++ b/ilsp/server.py @@ -67,8 +67,10 @@ async def _ws_proxy(request: web.Request, host: str, port: int) -> web.WebSocket await ws.prepare(request) try: - tcp_reader, tcp_writer = await asyncio.open_connection(host, port) - except OSError as exc: + tcp_reader, tcp_writer = await asyncio.wait_for( + asyncio.open_connection(host, port), timeout=3.0 + ) + except (OSError, asyncio.TimeoutError) as exc: logger.error("Cannot connect to LSP on %s:%d — %s", host, port, exc) await ws.close(code=1011, message=b"LSP backend unavailable") return ws