Jump to solution
Verify

The Fix

Upgrade to version 0.7.2 or later.

Based on closed encode/httpx issue #140 · 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
@@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@ -from .adapters.redirects import RedirectAdapter from .backends.sync import SyncClient from .client import Client
repro.py
class LoggingHTTPAdapter(requests.adapters.HTTPAdapter): """Adapter to log request and response.""" def send(self, request, *args, **kwargs): sensitive_params = conf.SENSITIVE_PARAMS # transaction ID to identify the logs. trans_id = util.generate_uuid() headers = util.filter_sensitive_information( request.headers, sensitive_params ) log.info(f"<{trans_id}> Request: {request.method} {request.url}") log.info(f"<{trans_id}> Request headers: {headers}") log.info(f"<{trans_id}> Request body: {request.body}") resp = super().send(request, *args, **kwargs) headers = util.filter_sensitive_information( resp.headers, sensitive_params ) log.info(f"<{trans_id}> Response: {resp.status_code} {resp.reason}") log.info(f"<{trans_id}> Response headers: {headers}") log.info(f"<{trans_id}> Response body: {resp.content}") # Store the transaction ID in the response object, so that it can be # added to the logs from test cases. resp.__dict__["transaction_id"] = trans_id return resp def mount_adapter(session): # currently we only have TimeoutHTTPAdapter and LoggingHTTPAdapter, # when we add more in the future, we can use this function to mount # our adapters. adapters = [LoggingHTTPAdapter()] for adapter in adapters: session.mount("http://", adapter) session.mount("https://", adapter)
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.7.2 or later.\nWhen NOT to use: This fix is not suitable for users requiring the old adapter system.\n\n

Why This Fix Works in Production

  • Trigger: Users were unable to implement custom logging adapters effectively.
  • Mechanism: Refactored the adapter system to improve flexibility and maintainability
  • Why the fix works: Refactored the adapter system to improve flexibility and maintainability. (first fixed release: 0.7.2).
Production impact:
  • If left unfixed, tail latency can spike under load and surface as timeouts/retries (amplifying incident impact).

Why This Breaks in Prod

  • Refactored the adapter system to improve flexibility and maintainability
  • Production symptom (often without a traceback): Users were unable to implement custom logging adapters effectively.

Proof / Evidence

  • GitHub issue: #140
  • Fix PR: https://github.com/encode/httpx/pull/55
  • First fixed release: 0.7.2
  • 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.44

Discussion

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

“The Dispatcher interface is a very close equivalent to the Adapter interface”
@lovelydinosaur · 2019-07-24 · source
“Excellent. I'll give that a shot tomorrow. Thanks!”
@StephenBrown2 · 2019-07-24 · source
“This issue is no longer needed it seems? Reopen if I'm wrong here :)”
@sethmlarson · 2019-07-28 · source
“Yup, the custom Dispatcher worked for me, was going to update on Monday once I had a bit more testing done. Good to close :+1:”
@StephenBrown2 · 2019-07-28 · source

Failure Signature (Search String)

  • Users were unable to implement custom logging adapters effectively.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Users were unable to implement custom logging adapters effectively.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Users were unable to implement custom logging adapters effectively.

Minimal Reproduction

repro.py
class LoggingHTTPAdapter(requests.adapters.HTTPAdapter): """Adapter to log request and response.""" def send(self, request, *args, **kwargs): sensitive_params = conf.SENSITIVE_PARAMS # transaction ID to identify the logs. trans_id = util.generate_uuid() headers = util.filter_sensitive_information( request.headers, sensitive_params ) log.info(f"<{trans_id}> Request: {request.method} {request.url}") log.info(f"<{trans_id}> Request headers: {headers}") log.info(f"<{trans_id}> Request body: {request.body}") resp = super().send(request, *args, **kwargs) headers = util.filter_sensitive_information( resp.headers, sensitive_params ) log.info(f"<{trans_id}> Response: {resp.status_code} {resp.reason}") log.info(f"<{trans_id}> Response headers: {headers}") log.info(f"<{trans_id}> Response body: {resp.content}") # Store the transaction ID in the response object, so that it can be # added to the logs from test cases. resp.__dict__["transaction_id"] = trans_id return resp def mount_adapter(session): # currently we only have TimeoutHTTPAdapter and LoggingHTTPAdapter, # when we add more in the future, we can use this function to mount # our adapters. adapters = [LoggingHTTPAdapter()] for adapter in adapters: session.mount("http://", adapter) session.mount("https://", adapter)

What Broke

Users were unable to implement custom logging adapters effectively.

Why It Broke

Refactored the adapter system to improve flexibility and maintainability

Fix Options (Details)

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

Upgrade to version 0.7.2 or later.

When NOT to use: This fix is not suitable for users requiring the old adapter system.

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

Option D — Guard side-effects with OnceOnly Guardrail for side-effects

Mitigate duplicate external side-effects under retries/timeouts/agent loops by gating the operation before calling external systems.

  • Place OnceOnly between your code/agent and real side-effects (Stripe, emails, CRM, APIs).
  • Use a stable key per side-effect (e.g., customer_id + action + idempotency_key).
  • Fail-safe: configure fail-open vs fail-closed based on blast radius and spend risk.
Show example snippet (optional)
onceonly.py
from onceonly import OnceOnly import os once = OnceOnly(api_key=os.environ["ONCEONLY_API_KEY"], fail_open=True) # Stable idempotency key per real side-effect. # Use a request id / job id / webhook delivery id / Stripe event id, etc. event_id = "evt_..." # replace key = f"stripe:webhook:{event_id}" res = once.check_lock(key=key, ttl=3600) if res.duplicate: return {"status": "already_processed"} # Safe to execute the side-effect exactly once. handle_event(event_id)

See OnceOnly SDK

When NOT to use: Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

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

First fixed release: 0.7.2

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 for users requiring the old adapter system.
  • Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

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.
  • Track RSS + object counts after deployments; alert on monotonic growth and GC pressure.
  • Add a long-running test that repeats the failing call path and asserts stable memory.

Version Compatibility Table

VersionStatus
0.7.2 Fixed

Related Issues

No related fixes found.

Sources

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