The Fix
pip install requests==2.32.0
Based on closed psf/requests issue #6628 · PR/commit linked
Production note: Watch p95/p99 latency and retry volume; timeouts can turn into retry storms and duplicate side-effects.
@@ -41,6 +41,16 @@ def __init__(self, *args, **kwargs):
InvalidJSONError.__init__(self, *self.args, **kwargs)
+ def __reduce__(self):
+ """
+ The __reduce__ method called when pickling the object must
# File api.py
from fastapi import FastAPI
from starlette.responses import PlainTextResponse
app = FastAPI()
@app.get("/")
async def root():
# An invalid json string returned by the endpoint that will trigger a JSONDecodeError when calling `res.json()`
s = '{"responseCode":["706"],"data":null}{"responseCode":["706"],"data":null}'
return PlainTextResponse(s, media_type="application/json", status_code=400)
# Run the API:
# $ uvicorn api:app --reload
#
# curl http://127.0.0.1:8000 will return the invalid json
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install requests==2.32.0\nWhen NOT to use: This fix is not suitable if the application relies on the current behavior of crashing on JSON errors.\n\n
Why This Fix Works in Production
- Trigger: result_item = result_reader.recv()
- Mechanism: JSONDecodeError instances can't be deserialized due to improper MRO in the class inheritance
- Why the fix works: Fixes a bug where JSONDecodeError instances can't be deserialized, causing a BrokenProcessPool error in process pools. (first fixed release: 2.32.0).
- 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.11 in real deployments (not just unit tests).
- JSONDecodeError instances can't be deserialized due to improper MRO in the class inheritance
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #6628
- Fix PR: https://github.com/psf/requests/pull/6629
- First fixed release: 2.32.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.60
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.43
Verified Execution
We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.
- Status: PASS
- Ran: 2026-02-11T16:52:29Z
- Package: requests
- Fixed: 2.32.0
- Mode: fixed_only
- Outcome: ok
Logs
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“As mentioned I've raised https://github.com/psf/requests/pull/6629, hopefully the proposal makes sense.”
Failure Signature (Search String)
- result_item = result_reader.recv()
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "/usr/local/lib/python3.11/concurrent/futures/process.py", line 424, in wait_result_broken_or_wakeup
result_item = result_reader.recv()
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/multiprocessing/connection.py", line 251, in recv
return _ForkingPickler.loads(buf.getbuffer())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/requests/exceptions.py", line 41, in __init__
CompatJSONDecodeError.__init__(self, *args)
TypeError: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'
Stack trace
Error Message
-------------
CompatJSONDecodeError.__init__(self, *args)
E TypeError: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'
Minimal Reproduction
# File api.py
from fastapi import FastAPI
from starlette.responses import PlainTextResponse
app = FastAPI()
@app.get("/")
async def root():
# An invalid json string returned by the endpoint that will trigger a JSONDecodeError when calling `res.json()`
s = '{"responseCode":["706"],"data":null}{"responseCode":["706"],"data":null}'
return PlainTextResponse(s, media_type="application/json", status_code=400)
# Run the API:
# $ uvicorn api:app --reload
#
# curl http://127.0.0.1:8000 will return the invalid json
Environment
- Python: 3.11
What Broke
Invalid JSON responses cause the entire process pool to crash, halting all tasks.
Why It Broke
JSONDecodeError instances can't be deserialized due to improper MRO in the class inheritance
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install requests==2.32.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/psf/requests/pull/6629
First fixed release: 2.32.0
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- This fix is not suitable if the application relies on the current behavior of crashing on JSON errors.
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
- 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
| Version | Status |
|---|---|
| 2.32.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.