The Fix
Added HTTPConnection as a base class for both Request and WebSocket to support cookie functionality in WebSocket scopes.
Based on closed Kludex/starlette issue #240 · PR/commit linked
@@ -17,16 +17,15 @@ class ClientDisconnect(Exception):
-async def empty_receive() -> Message:
- raise RuntimeError("Receive channel has not been made available")
+class HTTPConnection(Mapping):
Option A — Apply the official fix\nAdded HTTPConnection as a base class for both Request and WebSocket to support cookie functionality in WebSocket scopes.\nWhen NOT to use: This fix should not be used if the application does not require cookie support for websockets.\n\n
Why This Fix Works in Production
- Trigger: Authentication middleware for websockets failed due to lack of cookie support.
- Mechanism: Added HTTPConnection as a base class for both Request and WebSocket to support cookie functionality in WebSocket scopes.
Why This Breaks in Prod
- Production symptom (often without a traceback): Authentication middleware for websockets failed due to lack of cookie support.
Proof / Evidence
- GitHub issue: #240
- Fix PR: https://github.com/kludex/starlette/pull/270
- Reproduced locally: No (not executed)
- Last verified: 2026-02-12
- Confidence: 0.70
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.77
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Cookie support ought to be on WebSocket too - it’s just an oversight. Really we ought to include a common base class, HTTPConnection.”
Failure Signature (Search String)
- Authentication middleware for websockets failed due to lack of cookie support.
Copy-friendly signature
Failure Signature
-----------------
Authentication middleware for websockets failed due to lack of cookie support.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Authentication middleware for websockets failed due to lack of cookie support.
What Broke
Authentication middleware for websockets failed due to lack of cookie support.
Fix Options (Details)
Option A — Apply the official fix
Added HTTPConnection as a base class for both Request and WebSocket to support cookie functionality in WebSocket scopes.
Fix reference: https://github.com/kludex/starlette/pull/270
Last verified: 2026-02-12. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the application does not require cookie support for websockets.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.