Jump to solution
Details

The Fix

Upgrade to version 0.15.0 or later.

Based on closed encode/httpx issue #871 · 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%.

Open PR/Commit
@@ -1,5 +1,6 @@ import functools import typing +import warnings from types import TracebackType
fix.md
Option A — Upgrade to fixed release\nUpgrade to version 0.15.0 or later.\nWhen NOT to use: This fix is not applicable if you require the AsyncClient to operate without warnings.\n\n

Why This Fix Works in Production

  • Trigger: Users may experience resource leaks due to unclosed AsyncClient instances.
  • Mechanism: The AsyncClient was not warning users about unclosed instances, leading to potential resource leaks
  • Why the fix works: Added a warning for unclosed AsyncClient instances to prevent sending requests after being closed, addressing issue #871. (first fixed release: 0.15.0).
Production impact:
  • 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

  • The AsyncClient was not warning users about unclosed instances, leading to potential resource leaks
  • Production symptom (often without a traceback): Users may experience resource leaks due to unclosed AsyncClient instances.

Proof / Evidence

  • GitHub issue: #871
  • Fix PR: https://github.com/encode/httpx/pull/1197
  • First fixed release: 0.15.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.86

Discussion

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

“@florimondmanca closing all connections sounds fine but question is whether it is technically doable as close() is an async function and we cannot await it…”
@kamilglod · 2020-03-25 · confirmation · source
“@florimondmanca If anyone is not working on it. I would like to give it a try. 😄”
@Pradhvan · 2020-06-17 · source
“Hi @kamilglod Can you share what the UX for this in aiohttp looks like? (eg maybe a snippet of an interactive interpreter session…) I'm just…”
@florimondmanca · 2020-03-25 · source
“@florimondmanca should we add the similar check for httpx.Client?”
@cdeler · 2020-08-18 · source

Failure Signature (Search String)

  • Users may experience resource leaks due to unclosed AsyncClient instances.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Users may experience resource leaks due to unclosed AsyncClient instances.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Users may experience resource leaks due to unclosed AsyncClient instances.

What Broke

Users may experience resource leaks due to unclosed AsyncClient instances.

Why It Broke

The AsyncClient was not warning users about unclosed instances, leading to potential resource leaks

Fix Options (Details)

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

Upgrade to version 0.15.0 or later.

When NOT to use: This fix is not applicable if you require the AsyncClient to operate without warnings.

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/1197

First fixed release: 0.15.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 is not applicable if you require the AsyncClient to operate without warnings.

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.

Version Compatibility Table

VersionStatus
0.15.0 Fixed

Related Issues

No related fixes found.

Sources

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