Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Feature request: raise an exception on send() if client is already disconnected #650

Copy link
Copy link
@aldem

Description

@aldem
Issue body actions

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    asgiIssue related to ASGI protocolIssue related to ASGI protocol

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.