Jump to solution
Verify

The Fix

Upgrade to version 0.13.0 or later.

Based on closed encode/httpx issue #95 · PR/commit linked

Production note: Watch p95/p99 latency and retry volume; timeouts can turn into retry storms and duplicate side-effects.

Jump to Verify Open PR/Commit
@@ -242,6 +242,10 @@ async def open_uds_stream( return SocketStream(stream_reader=stream_reader, stream_writer=stream_writer) + def time(self) -> float: + loop = asyncio.get_event_loop() + return loop.time()
repro.py
File "/project/venv/lib/python3.7/site-packages/http3/client.py", line 145, in send_handling_redirects request, verify=verify, cert=cert, timeout=timeout File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection_pool.py", line 121, in send raise exc File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection_pool.py", line 116, in send request, verify=verify, cert=cert, timeout=timeout File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection.py", line 59, in send response = await self.h11_connection.send(request, timeout=timeout) File "/project/venv/lib/python3.7/site-packages/http3/dispatch/http11.py", line 53, in send await self._send_event(event, timeout) File "/project/venv/lib/python3.7/site-packages/http3/dispatch/http11.py", line 101, in _send_event await self.writer.write(data, timeout) File "/project/venv/lib/python3.7/site-packages/http3/concurrency.py", line 89, in write self.stream_writer.drain(), timeout.write_timeout File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/tasks.py", line 388, in wait_for return await fut File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/streams.py", line 348, in drain await self._protocol._drain_helper() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/streams.py", line 202, in _drain_helper raise ConnectionResetError('Connection lost')
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\nUpgrade to version 0.13.0 or later.\nWhen NOT to use: This fix should not be applied if the application does not use keep-alive connections.\n\n

Why This Fix Works in Production

  • Trigger: request, verify=verify, cert=cert, timeout=timeout
  • Mechanism: The library fails to detect lost connections when reacquiring connections from the pool
  • Why the fix works: Checks for connection aliveness when reacquiring connections from the pool, addressing the issue of lost connections. (first fixed release: 0.13.0).
Production impact:
  • If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).

Why This Breaks in Prod

  • Shows up under Python 3.7 in real deployments (not just unit tests).
  • The library fails to detect lost connections when reacquiring connections from the pool
  • Surfaces as: File "/project/venv/lib/python3.7/site-packages/http3/client.py", line 145, in send_handling_redirects

Proof / Evidence

  • GitHub issue: #95
  • Fix PR: https://github.com/encode/httpx/pull/627
  • First fixed release: 0.13.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.75
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.24

Discussion

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

“Alrighty”
@lovelydinosaur · 2019-07-08 · confirmation · source
“> Alrighty”
@rwboyer · 2019-08-25 · confirmation · source
“Could you break this down to the simplest possible reproduction? Which URL, what kind of request? Does it reproduce on a range of URLs, or…”
@lovelydinosaur · 2019-06-18 · repro detail · source
“Could be that it’s caused by https://github.com/encode/http3/issues/5 - will need to replicate, and then do some digging.”
@lovelydinosaur · 2019-06-18 · source

Failure Signature (Search String)

  • request, verify=verify, cert=cert, timeout=timeout

Error Message

Stack trace
error.txt
Error Message ------------- File "/project/venv/lib/python3.7/site-packages/http3/client.py", line 145, in send_handling_redirects request, verify=verify, cert=cert, timeout=timeout File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection_pool.py", line 121, in send raise exc File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection_pool.py", line 116, in send request, verify=verify, cert=cert, timeout=timeout File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection.py", line 59, in send response = await self.h11_connection.send(request, timeout=timeout) File "/project/venv/lib/python3.7/site-packages/http3/dispatch/http11.py", line 53, in send await self._send_event(event, timeout) File "/project/venv/lib/python3.7/site-packages/http3/dispatch/http11.py", line 101, in _send_event await self.writer.write(data, timeout) File "/project/venv/lib/python3.7/site-packages/http3/concurrency.py", line 89, in write self.stream_writer.drain(), timeout.write_timeout File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/tasks.py", line 388, in wait_for return await fut File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/streams.py", line 348, in drain await self._protocol._drain_helper() File "/usr/local/Cellar/python/3.7. ... (truncated) ...
Stack trace
error.txt
Error Message ------------- response = await self.session.post(path, json=body) File "/home/worker/.local/lib/python3.7/site-packages/httpx/client.py", line 484, in post trust_env=trust_env, File "/home/worker/.local/lib/python3.7/site-packages/httpx/client.py", line 626, in request trust_env=trust_env, File "/home/worker/.local/lib/python3.7/site-packages/httpx/client.py", line 650, in send trust_env=trust_env, File "/home/worker/.local/lib/python3.7/site-packages/httpx/client.py", line 265, in _get_response return await get_response(request) File "/home/worker/.local/lib/python3.7/site-packages/httpx/middleware/redirect.py", line 31, in __call__ response = await get_response(request) File "/home/worker/.local/lib/python3.7/site-packages/httpx/client.py", line 226, in get_response request, verify=verify, cert=cert, timeout=timeout File "/home/worker/.local/lib/python3.7/site-packages/httpx/dispatch/connection_pool.py", line 126, in send raise exc File "/home/worker/.local/lib/python3.7/site-packages/httpx/dispatch/connection_pool.py", line 121, in send request, verify=verify, cert=cert, timeout=timeout File "/home/worker/.local/lib/python3.7/site-packages/httpx/dispatch/connection.py", line 65, in send response = await self.h11_connection.send(request, timeout=timeout) File "/home/worker/.local/lib/python3.7/site-packages/httpx/dispatch/http11.py", ... (truncated) ...

Minimal Reproduction

repro.py
File "/project/venv/lib/python3.7/site-packages/http3/client.py", line 145, in send_handling_redirects request, verify=verify, cert=cert, timeout=timeout File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection_pool.py", line 121, in send raise exc File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection_pool.py", line 116, in send request, verify=verify, cert=cert, timeout=timeout File "/project/venv/lib/python3.7/site-packages/http3/dispatch/connection.py", line 59, in send response = await self.h11_connection.send(request, timeout=timeout) File "/project/venv/lib/python3.7/site-packages/http3/dispatch/http11.py", line 53, in send await self._send_event(event, timeout) File "/project/venv/lib/python3.7/site-packages/http3/dispatch/http11.py", line 101, in _send_event await self.writer.write(data, timeout) File "/project/venv/lib/python3.7/site-packages/http3/concurrency.py", line 89, in write self.stream_writer.drain(), timeout.write_timeout File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/tasks.py", line 388, in wait_for return await fut File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/streams.py", line 348, in drain await self._protocol._drain_helper() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/streams.py", line 202, in _drain_helper raise ConnectionResetError('Connection lost')

Environment

  • Python: 3.7

What Broke

Users experience intermittent ConnectionResetError when making requests after idle periods.

Why It Broke

The library fails to detect lost connections when reacquiring connections from the pool

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

Upgrade to version 0.13.0 or later.

When NOT to use: This fix should not be applied if the application does not use keep-alive connections.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/encode/httpx/pull/627

First fixed release: 0.13.0

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 should not be applied if the application does not use keep-alive connections.

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

  • 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.
  • Make timeouts explicit and test them (unit + integration) to avoid silent behavior changes.
  • Instrument retries (attempt count + reason) and alert on spikes to catch dependency slowdowns.

Version Compatibility Table

VersionStatus
0.13.0 Fixed

Related Issues

No related fixes found.

Sources

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