Closed vytas7 closed 1 month ago
I agree that the primary impact is likely the websocket, since in the other cases the sent is confined to the app class, allowing the orerror to be propagated without much issues to the api server.
For websocket we likely need to close it if send raises an os error
I don't think we need to close the websocket at hand, because closing is performed via send()
by sending an appropriate ASGI event (which is moot since it is exactly what raises OSError
).
However, we'll need to make sure that we properly reraise this exception as WebSocketDisconnected
. (Probably we could even use the raise WebSocketDisconnected(...) from io_ex
form? :thinking:)
my closing I meant cleaning up the internal state, like the _BufferedReceiver
. regarding the re-raise, seems like an appropriate behaviour
The last paragraph of Lost Connections also needs to be reworded:
Note also that some ASGI server implementations do not strictly follow the ASGI spec in this regard, and in fact will raise an error when the app attempts to send a message after the client disconnects. If testing reveals this to be the case for your ASGI server of choice, Falcon’s own receive queue can be safely disabled.
(emphasis mine)
:arrow_right: Conversely, these implementations do actually follow the spec version 2.4.
I split the HTTP part to another issue (#2323), and address only the WebSocket part for 4.0.
In the ASGI HTTP & WebSocket protocol version
2.4
, callingsend()
on a closed connection should raise anOSError
.See also Disconnected Client -
send
exception:Do we need to adjust our code? Or do we just bubble this up to the app server?
Note: this issue is aiming to address this only for WebSocket. The same issue in the usual HTTP protocol is tracked as #2323.
See also:
1483
1808