WebSocketDisconnectEvent
is not handling the reason
field
#2299
Unanswered
frankie567
asked this question in
Potential Issue
Replies: 1 comment
-
Asked the question |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While investigating an issue with HTTPX WS, I noticed that, when a client disconnects, Uvicorn handles the
code
but not thereason
:uvicorn/uvicorn/protocols/websockets/wsproto_impl.py
Line 214 in a2219eb
uvicorn/uvicorn/protocols/websockets/websockets_impl.py
Line 384 in a2219eb
After having a look at the ASGI specification, it seems indeed that the Disconnect (receive) event does not support this field: https://asgi.readthedocs.io/en/latest/specs/www.html#disconnect-receive-event-ws
However, from Starlette, the
WebSocketDisconnect
class does have a field intended forreason
, but probably never used (at least when running behind Uvicorn):https://github.com/encode/starlette/blob/4e453ce91940cc7c995e6c728e3fdf341c039056/starlette/websockets.py#L19-L22
So, I'm not sure where the problem comes from:
reason
field should probably a thing in the Disconnect (receive) eventreason
field from the Starlette'sWebSocketDisconnect
exception?reason
field?Insights about this would be welcome :)
Beta Was this translation helpful? Give feedback.
All reactions