Avoid noisy output on normal WebSocket closing.

This commit is contained in:
2026-05-02 16:12:42 +00:00
parent b13f08eab2
commit 338c74de69
+7
View File
@@ -2,6 +2,7 @@ import time
from functools import wraps
import msgspec
import websockets.exceptions
from sanic import errorpages
from sanic.exceptions import SanicException
from sanic.log import logger
@@ -67,6 +68,12 @@ def websocket_wrapper(handler):
try:
await auth.verify(request)
await handler(request, ws, *args, **kwargs)
except (
websockets.exceptions.ConnectionClosedOK,
websockets.exceptions.ConnectionClosedError,
):
# Normal websocket closure - already logged in access log
pass
except Exception as e:
context, code, message = {}, 500, str(e) or "Internal Server Error"
if isinstance(e, SanicException):