Closed alixlahuec closed 3 weeks ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
a7cc121
) to head (8ec440c
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
✅ Did a final smoke test with ER, with both sessions & read/writes 🚀
Problem
When using multiple sessions, we've seen sporadic issues coming from the injected middlewares where the response body is missing, causing errors due to a mismatch with the promised
Content-Length
. We've also observed a significant increase in endpoint latency.Besides, the middleware class we're using,
BaseHTTPMiddleware
, is no longer the recommended way of writing middlewares for Starlette. It's known to have functional issues and does not scale well (see discussion on this FastAPI issue, discussion on this Starlette issue, and this performance benchmark).Solution
Refactor the middleware used to inject sessions into the request, to be pure ASGI middleware.
Related
Validation
✅ Tests are passing ✅ ER smoke tests with 2 sessions - calls are successful, both middlewares are present and executed (sample request - only the default session is used, sample request - both sessions are used)