Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Stop streaming response when client disconnects #1342

@bo5o

Description

@bo5o

If the client disconnects from a StreamingResponse, the server does not stop the request, but keeps it alive and the stream generator running (which is problematic with an endless live stream or similar).

The problem is. that in Starlette v0.13.2 there was no listener task to cancel the streaming response in case of an early disconnect, which was fixed in this commit. The fix was released in Starlette v0.13.3, but is not yet reflected in FastAPI, because Starlette is pinned to v0.13.2 in the pyproject.toml.

I guess this issue can be closed as soon as FastAPI upgrades Starlette.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions