fix: add 3s timeout to LSP backend connection (handles CI firewall drops)
Some checks failed
Build and Deploy iLSP / test (push) Failing after 27s
Build and Deploy iLSP / build-and-deploy (push) Has been skipped

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.
This commit is contained in:
Henrik Jess Nielsen
2026-05-10 15:13:03 +02:00
parent a708cb779e
commit 404bd1418d

View File

@@ -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