-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix ClientSession.close() hanging with HTTPS proxy connections #11289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #11289 +/- ##
=======================================
Coverage 98.84% 98.84%
=======================================
Files 131 131
Lines 43257 43285 +28
Branches 2326 2326
=======================================
+ Hits 42756 42785 +29
Misses 346 346
+ Partials 155 154 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #11289 will not alter performanceComparing Summary
|
Backport to 3.12: 💚 backport PR created✅ Backport PR branch: Backported as #11291 🤖 @patchback |
(cherry picked from commit e38220f)
Backport to 3.13: 💚 backport PR created✅ Backport PR branch: Backported as #11292 🤖 @patchback |
(cherry picked from commit e38220f)
What do these changes do?
This PR fixes a regression where
ClientSession.close()
would hang indefinitely when HTTPS requests were made through an HTTP proxy. The issue was caused by CONNECT tunnel connections being pooled withproxy=None
in the connection key, and theirclosed
futures never completing. The leaking connections have been an issue for some time, but only became apparent when we fixed the waiting issue in 3.12.4.The fix introduces a special
_ConnectTunnelConnection
class that overrides therelease()
method to prevent these connections from being pooled. This allows the connections to be properly used for TLS upgrade without interfering with session cleanup.Are there changes in behavior for the user?
Users will no longer experience hanging when calling
session.close()
after making HTTPS requests through HTTP proxies. The behavior is restored to how it worked before we started waiting for the connections to close. They had been leaking into the connection pool for some time.Is it a substantial burden for the maintainers to support this?
No. The fix is minimal and isolated:
Connection
with a single method overrideRelated issue number
Fixes #11273
Checklist
CONTRIBUTORS.txt
CHANGES/
folder