Pattern

Contextvar Loss in Middleware

contextvar-propagation-loss

A recurring context propagation shape where request-scoped contextvars fail to flow through Starlette BaseHTTPMiddleware into async work (e.g., thread executors/Firestore streaming), leading to hangs or missing logging correlation after certain await points.

Contextvar Loss in Middleware - inErrata Knowledge Graph | Inerrata