The Fix
pip install urllib3==2.6.0
Based on closed urllib3/urllib3 issue #3710 · PR/commit linked
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+Improved the performance of content decoding by optimizing ``BytesQueueBuffer`` class.
diff --git a/src/urllib3/response.py b/src/urllib3/response.py
index d427e7148d..3df98184de 100644
from compression import zstd
import io
import timeit
from urllib3.response import HTTPResponse
data = b"A" * (1024 * 1024 * 1024) # 1 GB
compressed_data = zstd.ZstdCompressor().compress(data)
def decompress():
fp = io.BytesIO(compressed_data)
r = HTTPResponse(fp, headers={"content-encoding": "zstd"}, preload_content=False)
while r.read(32 * 1024):
pass
time_taken = timeit.timeit(decompress, number=10)
print(f"Decompression time: {time_taken:.2f} seconds")
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install urllib3==2.6.0\nWhen NOT to use: This fix should not be used if backward compatibility with older versions is required.\n\n
Why This Fix Works in Production
- Trigger: OpenSSL 3.0.14 4 Jun 2024
- Mechanism: Improves the speed of `BytesQueueBuffer.get()` by using memoryview, solving the problem described in #3710.
- Why the fix works: Improves the speed of `BytesQueueBuffer.get()` by using memoryview, solving the problem described in #3710. (first fixed release: 2.6.0).
Why This Breaks in Prod
- Shows up under Python 3.12.5 in real deployments (not just unit tests).
- Production symptom (often without a traceback): OpenSSL 3.0.14 4 Jun 2024
Proof / Evidence
- GitHub issue: #3710
- Fix PR: https://github.com/urllib3/urllib3/pull/3711
- First fixed release: 2.6.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.60
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“FYI, we did further improvements in c19571de34c47de3a766541b041637ba5f716ed7”
Failure Signature (Search String)
- OpenSSL 3.0.14 4 Jun 2024
- CPU: 13th Gen Intel(R) Core(TM) i5-13500
Copy-friendly signature
Failure Signature
-----------------
OpenSSL 3.0.14 4 Jun 2024
CPU: 13th Gen Intel(R) Core(TM) i5-13500
Error Message
Signature-only (no traceback captured)
Error Message
-------------
OpenSSL 3.0.14 4 Jun 2024
CPU: 13th Gen Intel(R) Core(TM) i5-13500
Minimal Reproduction
from compression import zstd
import io
import timeit
from urllib3.response import HTTPResponse
data = b"A" * (1024 * 1024 * 1024) # 1 GB
compressed_data = zstd.ZstdCompressor().compress(data)
def decompress():
fp = io.BytesIO(compressed_data)
r = HTTPResponse(fp, headers={"content-encoding": "zstd"}, preload_content=False)
while r.read(32 * 1024):
pass
time_taken = timeit.timeit(decompress, number=10)
print(f"Decompression time: {time_taken:.2f} seconds")
Environment
- Python: 3.12.5
- urllib3: 0.1
What Broke
Content retrieval time was significantly slower when decoding gzipped data.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==2.6.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/urllib3/urllib3/pull/3711
First fixed release: 2.6.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if backward compatibility with older versions is required.
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 CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
- 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.
Version Compatibility Table
| Version | Status |
|---|---|
| 2.6.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.