-
-
Notifications
You must be signed in to change notification settings - Fork 109
Description
Currently, the response is simply "swallowed" if the client is disconnected in the meantime. It would be nice to let the app be aware of such cases and raise an exception in the send()
method: https://asgi.readthedocs.io/en/latest/specs/www.html#disconnected-client-send-exception.
Granian
logs a message [INFO] ASGI transport error: SendError { .. }
on every failed send, and the log becomes cluttered, while we don't even know which request (and client/ip) is causing this. This is especially annoying when the response has lots of chunks, i.e. send()
is called thousands of times.
Use case: both malicious and erroneous disconnections can occur, and this hurts the app if requests are either expensive or take some time to finish. If the app is aware, it will have a chance to at least log such issues, allowing for subsequent analysis to take appropriate action, or to stop sending a long response body if the client suddenly disconnects.
PS: Ideally, of course, it would be nice to somehow signal the app that the client is disconnected, giving it a chance to cancel an active request. Unfortunately, this is beyond the current specifications...