The Fix
Fixes a regression where ClientSession.close() would hang indefinitely when HTTPS requests were made through an HTTP proxy.
Based on closed aio-libs/aiohttp issue #11273 · 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 @@
+Fixed :py:meth:`ClientSession.close() <aiohttp.ClientSession.close>` hanging indefinitely when using HTTPS requests through HTTP proxies -- by :user:`bdraco`.
diff --git a/aiohttp/connector.py b/aiohttp/connector.py
index 1c96ff42457..e1288424bff 100644
import asyncio
from aiohttp import ClientSession
async def main():
proxy = ""
session = ClientSession(proxy=proxy)
async with session.get(
"https://api.ipify.org/",
) as response:
ip = await response.text()
print("Closing session...")
await session.close()
print("Done")
return ip
asyncio.run(main())
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\nFixes a regression where ClientSession.close() would hang indefinitely when HTTPS requests were made through an HTTP proxy.\nWhen NOT to use: This fix should not be used if the application relies on the previous behavior of connection pooling.\n\n
Why This Fix Works in Production
- Trigger: Regression when closing session
- Mechanism: The regression was caused by CONNECT tunnel connections being pooled with proxy=None, leading to hanging futures
- 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
- Shows up under Python 3.13.5 in real deployments (not just unit tests).
- The regression was caused by CONNECT tunnel connections being pooled with proxy=None, leading to hanging futures
- Production symptom (often without a traceback): Regression when closing session
Proof / Evidence
- GitHub issue: #11273
- Fix PR: https://github.com/aio-libs/aiohttp/pull/11289
- 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.62
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“So this only happens when the remote is ssl HTTP through proxy works fine, HTTPS through proxy: Creates a proxy=None connection (the CONNECT tunnel), session…”
“> Successfully installed aiohttp-3.12.13 > > > > import asyncio > from aiohttp import ClientSession > > async def main(): > proxy = "" >…”
“I just saw the email show up. I'm traveling today and in flight. I'll look when I am on the ground and time adjusted”
“We are going to try to do a release this week. I'm working on a PR”
Failure Signature (Search String)
- Regression when closing session
- [V3.12.4](https://github.com/aio-libs/aiohttp/releases/tag/v3.12.4) Introduced a regression, in which, session with some proxies can't be closed.
Copy-friendly signature
Failure Signature
-----------------
Regression when closing session
[V3.12.4](https://github.com/aio-libs/aiohttp/releases/tag/v3.12.4) Introduced a regression, in which, session with some proxies can't be closed.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Regression when closing session
[V3.12.4](https://github.com/aio-libs/aiohttp/releases/tag/v3.12.4) Introduced a regression, in which, session with some proxies can't be closed.
Minimal Reproduction
import asyncio
from aiohttp import ClientSession
async def main():
proxy = ""
session = ClientSession(proxy=proxy)
async with session.get(
"https://api.ipify.org/",
) as response:
ip = await response.text()
print("Closing session...")
await session.close()
print("Done")
return ip
asyncio.run(main())
Environment
- Python: 3.13.5
What Broke
Closing the session hangs indefinitely when using HTTPS requests through HTTP proxies.
Why It Broke
The regression was caused by CONNECT tunnel connections being pooled with proxy=None, leading to hanging futures
Fix Options (Details)
Option A — Apply the official fix
Fixes a regression where ClientSession.close() would hang indefinitely when HTTPS requests were made through an HTTP proxy.
Fix reference: https://github.com/aio-libs/aiohttp/pull/11289
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the application relies on the previous behavior of connection pooling.
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
- 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.