Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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
repro.py
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.)
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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`.
Production impact:
  • 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

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”
Issue thread · issue description · source

Failure Signature (Search String)

  • if reqStream.total_bytes:

Error Message

Stack trace
error.txt
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

repro.py
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`.

When NOT to use: Do not use this fix if the `total_bytes` attribute is not required for your application logic.

Fix reference: https://github.com/aio-libs/aiohttp/pull/10387

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

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

verify
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.