Skip to content

The agent that grows with you

fix(gateway): bound go_dormant ws.close with teardown timeout

kshitij9c88625e25c9
diff --git a/gateway/relay/ws_transport.py b/gateway/relay/ws_transport.py
index 442453ab74b..07981a327e7 100644
--- a/gateway/relay/ws_transport.py
+++ b/gateway/relay/ws_transport.py
@@ -670,9 +670,11 @@ class WebSocketRelayTransport:
# flip us back to a fast reconnect.
self._dormant = True
try:
- await self._ws.close()
- except Exception: # noqa: BLE001 - best-effort; the reader still ends + arms reconnect
- logger.debug("relay go_dormant: ws.close() raised", exc_info=True)
+ await asyncio.wait_for(
+ self._ws.close(), timeout=_TEARDOWN_AWAIT_TIMEOUT_S
+ )
+ except (asyncio.TimeoutError, Exception): # noqa: BLE001 - best-effort; the reader still ends + arms reconnect
+ logger.debug("relay go_dormant: ws.close() raised or timed out", exc_info=True)
return acked
async def _send_inbound_ack(self, buffer_id: str) -> None: