Change8
Error2 reports

Fix BrokenResourceError

in Starlette

Solution

BrokenResourceError in Starlette often arises when attempting to use a request or websocket object after the connection has been closed or finalized, typically in background tasks or middleware. To fix this, ensure you're not accessing request/websocket properties after the response has been sent or the connection is closed; copy needed data from the request/websocket *before* starting background tasks, or use lifespan events to manage resources tied to the request lifecycle.

Timeline

First reported:Feb 28, 2025
Last reported:Apr 9, 2025

Need More Help?

View the full changelog and migration guides for Starlette

View Starlette Changelog