Jump to solution
Details

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

Open PR/Commit
@@ -17,16 +17,15 @@ class ClientDisconnect(Exception): -async def empty_receive() -> Message: - raise RuntimeError("Receive channel has not been made available") +class HTTPConnection(Mapping):
fix.md
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

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.”
@lovelydinosaur · 2018-11-29 · source

Failure Signature (Search String)

  • Authentication middleware for websockets failed due to lack of cookie support.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Authentication middleware for websockets failed due to lack of cookie support.

Error Message

Signature-only (no traceback captured)
error.txt
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.

When NOT to use: This fix should not be used if the application does not require cookie support for websockets.

Fix reference: https://github.com/kludex/starlette/pull/270

Last verified: 2026-02-12. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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.