Jump to solution
Details

The Fix

Changed `RequestInfo` to be a `NamedTuple` to improve performance, making it 2.7x faster to create.

Based on closed aio-libs/aiohttp issue #9504 · 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%.

Open PR/Commit
@@ -0,0 +1 @@ @@ -0,0 +1 @@ +Changed ``ClientRequest.request_info`` to be a `NamedTuple` to improve client performance -- by :user:`bdraco`. diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 9c86d935011..59a191d19fe 100644
fix.md
Option A — Apply the official fix\nChanged `RequestInfo` to be a `NamedTuple` to improve performance, making it 2.7x faster to create.\nWhen NOT to use: This fix is not suitable if backward compatibility with existing code is a concern.\n\n

Why This Fix Works in Production

  • Trigger: """Update destination host, port and connection type (ssl)."""
  • Mechanism: RequestInfo was implemented as a dataclass instead of a NamedTuple, affecting performance
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

  • RequestInfo was implemented as a dataclass instead of a NamedTuple, affecting performance
  • Production symptom (often without a traceback): """Update destination host, port and connection type (ssl)."""

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“<img width="1500" alt="Screenshot 2024-11-05 at 8 42 07 PM" src="https://github.com/user-attachments/assets/92add3df-591f-4bfd-a138-db724e9414b6"> Production shows quite a bit of time making this one”
@bdraco · 2024-11-06 · source
“I really doubt if we have the real bottleneck here”
@asvetlov · 2024-11-06 · source
“> Technically every namedtuple <-> attrs <-> dataclasses change is not 100% backward compatible, that's why I'm not super exciting in mutation of such things”
@Dreamsorcerer · 2024-11-06 · source
“This keeps coming up on production profiles so there is something there. It needs to be benchmarked and quantified first.”
@bdraco · 2024-11-06 · source

Failure Signature (Search String)

  • """Update destination host, port and connection type (ssl)."""
  • <img width="1500" alt="Screenshot 2024-11-05 at 8 42 07 PM" src="https://github.com/user-attachments/assets/92add3df-591f-4bfd-a138-db724e9414b6">
Copy-friendly signature
signature.txt
Failure Signature ----------------- """Update destination host, port and connection type (ssl).""" <img width="1500" alt="Screenshot 2024-11-05 at 8 42 07 PM" src="https://github.com/user-attachments/assets/92add3df-591f-4bfd-a138-db724e9414b6">

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- """Update destination host, port and connection type (ssl).""" <img width="1500" alt="Screenshot 2024-11-05 at 8 42 07 PM" src="https://github.com/user-attachments/assets/92add3df-591f-4bfd-a138-db724e9414b6">

What Broke

In production, creating RequestInfo instances led to performance bottlenecks.

Why It Broke

RequestInfo was implemented as a dataclass instead of a NamedTuple, affecting performance

Fix Options (Details)

Option A — Apply the official fix

Changed `RequestInfo` to be a `NamedTuple` to improve performance, making it 2.7x faster to create.

When NOT to use: This fix is not suitable if backward compatibility with existing code is a concern.

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

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

  • This fix is not suitable if backward compatibility with existing code is a concern.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.