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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user