Jump to solution
Verify

The Fix

Upgrade to version 0.13.3 or later.

Based on closed Kludex/uvicorn issue #894 · 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%.

Jump to Verify Open PR/Commit
@@ -1,5 +1,6 @@ import asyncio import logging +import signal from gunicorn.workers.base import Worker
repro.py
import subprocess from fastapi import FastAPI app = FastAPI() @app.post("/run") def run_subprocess(): result = subprocess.run( ["python", "-c", "import sys; sys.exit(1)"], capture_output=True ) return {"returncode": result.returncode}
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.3 or later.\nWhen NOT to use: This fix should not be applied if the application does not use subprocesses.\n\n

Why This Fix Works in Production

  • Trigger: In other words, remove anything that doesn't make the bug go away.
  • Mechanism: The UvicornWorker does not reset signal handlers, causing incorrect subprocess return codes
  • Why the fix works: Fix resetting signals in Gunicorn UvicornWorker to ensure subprocess return codes are correctly captured. (first fixed release: 0.13.3).
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

  • Shows up under Python 3.8.5 in real deployments (not just unit tests).
  • The UvicornWorker does not reset signal handlers, causing incorrect subprocess return codes
  • Production symptom (often without a traceback): In other words, remove anything that doesn't make the bug go away.

Proof / Evidence

  • GitHub issue: #894
  • Fix PR: https://github.com/kludex/uvicorn/pull/895
  • First fixed release: 0.13.3
  • 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.69

Discussion

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

“Was able to reproduce with a Starlette app as well. With plain Uvicorn: always returns 1. With Gunicorn: always getting 0 When running off from…”
@florimondmanca · 2020-12-29 · source
“Awesome! Thanks @florimondmanca ! :rocket: :coffee:”
@tiangolo · 2020-12-29 · source

Failure Signature (Search String)

  • In other words, remove anything that doesn't make the bug go away.
  • <!-- Any tracebacks, screenshots, etc. that can help understanding the problem.
Copy-friendly signature
signature.txt
Failure Signature ----------------- In other words, remove anything that doesn't make the bug go away. <!-- Any tracebacks, screenshots, etc. that can help understanding the problem.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- In other words, remove anything that doesn't make the bug go away. <!-- Any tracebacks, screenshots, etc. that can help understanding the problem.

Minimal Reproduction

repro.py
import subprocess from fastapi import FastAPI app = FastAPI() @app.post("/run") def run_subprocess(): result = subprocess.run( ["python", "-c", "import sys; sys.exit(1)"], capture_output=True ) return {"returncode": result.returncode}

Environment

  • Python: 3.8.5

What Broke

Subprocess return codes are often reported as 0 instead of the actual exit code.

Why It Broke

The UvicornWorker does not reset signal handlers, causing incorrect subprocess return codes

Fix Options (Details)

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

Upgrade to version 0.13.3 or later.

When NOT to use: This fix should not be applied if the application does not use subprocesses.

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

Fix reference: https://github.com/kludex/uvicorn/pull/895

First fixed release: 0.13.3

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 subprocesses.

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

  • Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
  • Pin production dependencies and upgrade only with a reproducible test that hits the failing path.

Version Compatibility Table

VersionStatus
0.13.3 Fixed

Related Issues

No related fixes found.

Sources

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