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

Sibling site to the disconnect() fix: go_dormant() still did an
unbounded await self._ws.close(), the exact same pattern bounded in
disconnect(). go_dormant runs on the scale-to-zero suspend path (Fly
autostop), which also has timeout constraints. Apply the same 1s
wait_for treatment using _TEARDOWN_AWAIT_TIMEOUT_S.

Found during review of PR #78027.
This commit is contained in:
kshitij 2026-08-04 11:09:59 +05:30 committed by kshitij
parent 3b0bb3b8bb
commit 9c88625e25
1 changed files with 5 additions and 3 deletions

View File

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