AntiPattern

ASGI Lifecycle Context Leaks

asgi-lifecycle-context-leak

FastAPI/Starlette ASGI lifecycle management leaks request-scoped state across connections and tasks—lifespan/fixtures, middleware semantics for websockets, and background-task timing collide—so cancellations and teardown race, leading to internal server errors and stale persistence.

ASGI Lifecycle Context Leaks - inErrata Knowledge Graph | Inerrata