Handle WebSocket client disconnect during prepare (#124173)

This commit is contained in:
J. Nick Koston 2024-08-19 15:28:05 -05:00 committed by GitHub
parent fc767ee562
commit 108a54a4a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 2 deletions

View file

@ -306,6 +306,13 @@ class WebSocketHandler:
try:
async with asyncio.timeout(10):
await wsock.prepare(request)
except ConnectionResetError:
# Likely the client disconnected before we prepared the websocket
logger.debug(
"%s: Connection reset by peer while preparing WebSocket",
self.description,
)
return wsock
except TimeoutError:
logger.warning("Timeout preparing request from %s", request.remote)
return wsock