The Fix
Restores the missing `total_bytes` attribute to `EmptyStreamReader`.
Based on closed aio-libs/aiohttp issue #10386 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+Restored the missing ``total_bytes`` attribute to ``EmptyStreamReader`` -- by :user:`bdraco`.
diff --git a/aiohttp/streams.py b/aiohttp/streams.py
index ca7a420c6d5..db22f162396 100644
if reqStream.total_bytes:
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'EmptyStreamReader' object has no attribute 'total_bytes'
(TB snippet from our code - with reqStream being an aiohttp EmptyStreamReader in that moment.)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\nRestores the missing `total_bytes` attribute to `EmptyStreamReader`.\nWhen NOT to use: Do not use this fix if the `total_bytes` attribute is not required for your application logic.\n\n
Why This Fix Works in Production
- Trigger: if reqStream.total_bytes:
- Mechanism: Restores the missing `total_bytes` attribute to `EmptyStreamReader`.
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Surfaces as: if reqStream.total_bytes:
Proof / Evidence
- GitHub issue: #10386
- Fix PR: https://github.com/aio-libs/aiohttp/pull/10387
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.80
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.56
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“### Describe the bug EmptyStreamReader does **no** longer provide the attribute total_bytes. (It looks like the introduction of __slots__ in StreamReader might be the reason - in combination with EmptyStreamReader.__init__ not calling Strea”
Failure Signature (Search String)
- if reqStream.total_bytes:
Error Message
Stack trace
Error Message
-------------
if reqStream.total_bytes:
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'EmptyStreamReader' object has no attribute 'total_bytes'
(TB snippet from our code - with reqStream being an aiohttp EmptyStreamReader in that moment.)
Minimal Reproduction
if reqStream.total_bytes:
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'EmptyStreamReader' object has no attribute 'total_bytes'
(TB snippet from our code - with reqStream being an aiohttp EmptyStreamReader in that moment.)
What Broke
Accessing `total_bytes` on `EmptyStreamReader` raises an `AttributeError`, causing potential application errors.
Fix Options (Details)
Option A — Apply the official fix
Restores the missing `total_bytes` attribute to `EmptyStreamReader`.
Fix reference: https://github.com/aio-libs/aiohttp/pull/10387
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if the `total_bytes` attribute is not required for your application logic.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
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.