The Fix
pip install urllib3==2.2.0
Based on closed urllib3/urllib3 issue #3305 · 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%.
@@ -67,7 +67,7 @@ jobs:
experimental: false
nox-session: test-pypy
- - python-version: "pypy-3.9"
+ - python-version: "pypy-3.9-v7.3.13"
os: ubuntu-latest
nox -s ${NOX_SESSION:-test-$PYTHON_VERSION}
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
pythonLocation: /opt/hostedtoolcache/PyPy/3.9.18/x64
Python_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.18/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.18/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.18/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/PyPy/3.9.18/x64/bin/lib/pkgconfig
PYTHON_VERSION: pypy-3.9
NOX_SESSION: test-pypy3.9
nox > Running session test-pypy3.9
nox > Creating virtual environment (virtualenv) using pypy3.9 in .nox/test-pypy3-9
nox > python -m pip install -r dev-requirements.txt
nox > python -m pip install '.[socks,brotli,zstd,h2]'
nox > pip --version
pip 23.3.1 from /home/runner/work/urllib3/urllib3/.nox/test-pypy3-9/lib/pypy3.9/site-packages/pip (python 3.9)
nox > python --version
Python 3.9.18 (9c4f8ef178b6, Jan 14 2024, 11:28:13)
[PyPy 7.3.15 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]
nox > python -c 'import struct; print(struct.calcsize('"'"'P'"'"') * 8)'
64
nox > python -m OpenSSL.debug
pyOpenSSL: 23.2.0
cryptography: 41.0.6
cffi: 1.16.0
cryptography's compiled against OpenSSL: OpenSSL 3.1.4 24 Oct 2023
cryptography's linked OpenSSL: OpenSSL 3.1.4 24 Oct 2023
Python's OpenSSL: OpenSSL 3.0.12 24 Oct 2023
Python executable: /home/runner/work/urllib3/urllib3/.nox/test-pypy3-9/bin/python
Python version: 3.9.18 (9c4f8ef178b6, Jan 14 2024, 11:28:13)
[PyPy 7.3.15 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]
Platform: linux
sys.path: ['/home/runner/work/urllib3/urllib3', '/opt/hostedtoolcache/PyPy/3.9.18/x64/lib/pypy3.9', '/home/runner/work/urllib3/urllib3/.nox/test-pypy3-9/lib/pypy3.9/site-packages']
nox > python -c 'import sys; print(sys.implementation.name, sys.version_info.releaselevel)'
nox > python -m coverage run --parallel-mode -m pytest -v -ra --color=yes --tb=native --durations=10 --strict-config --strict-markers test/
============================= test session starts ==============================
platform linux -- Python 3.9.18[pypy-7.3.15-final], pytest-7.4.2, pluggy-1.3.0 -- /home/runner/work/urllib3/urllib3/.nox/test-pypy3-9/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/urllib3/urllib3
configfile: pyproject.toml
plugins: anyio-4.2.0, timeout-2.1.0
collecting ... collected 2085 items / 1 skipped
test/test_collections.py::TestLRUContainer::test_maxsize PASSED [ 0%]
...
test/contrib/test_pyopenssl.py::TestSSL::test_is_ipaddress_false[v2.sg.media-imdb.com1] PASSED [ 51%]
Error: The operation was canceled.
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install urllib3==2.2.0\nWhen NOT to use: This fix is not suitable if a different PyPy version is required for compatibility.\n\n
Why This Fix Works in Production
- Trigger: Error: The operation was canceled.
- Mechanism: The CI was timing out due to the PyPy version causing excessive test durations
- Why the fix works: Pins the PyPy version in CI to prevent timeouts during tests. (first fixed release: 2.2.0).
- 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.9 in real deployments (not just unit tests).
- The CI was timing out due to the PyPy version causing excessive test durations
- Surfaces as: Error: The operation was canceled.
Proof / Evidence
- GitHub issue: #3305
- Fix PR: https://github.com/urllib3/urllib3/pull/3308
- First fixed release: 2.2.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.48
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“### Subject I have submitted a couple of PRs and it feel like I never got a passing CI , usually it fails on pypy3.9 with "cancelled after 30m". Looking at the logs of the CI jobs the test suite is around 50% when the CI job is killed. ###”
Failure Signature (Search String)
- Error: The operation was canceled.
Error Message
Stack trace
Error Message
-------------
Error: The operation was canceled.
Minimal Reproduction
nox -s ${NOX_SESSION:-test-$PYTHON_VERSION}
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
pythonLocation: /opt/hostedtoolcache/PyPy/3.9.18/x64
Python_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.18/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.18/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.18/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/PyPy/3.9.18/x64/bin/lib/pkgconfig
PYTHON_VERSION: pypy-3.9
NOX_SESSION: test-pypy3.9
nox > Running session test-pypy3.9
nox > Creating virtual environment (virtualenv) using pypy3.9 in .nox/test-pypy3-9
nox > python -m pip install -r dev-requirements.txt
nox > python -m pip install '.[socks,brotli,zstd,h2]'
nox > pip --version
pip 23.3.1 from /home/runner/work/urllib3/urllib3/.nox/test-pypy3-9/lib/pypy3.9/site-packages/pip (python 3.9)
nox > python --version
Python 3.9.18 (9c4f8ef178b6, Jan 14 2024, 11:28:13)
[PyPy 7.3.15 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]
nox > python -c 'import struct; print(struct.calcsize('"'"'P'"'"') * 8)'
64
nox > python -m OpenSSL.debug
pyOpenSSL: 23.2.0
cryptography: 41.0.6
cffi: 1.16.0
cryptography's compiled against OpenSSL: OpenSSL 3.1.4 24 Oct 2023
cryptography's linked OpenSSL: OpenSSL 3.1.4 24 Oct 2023
Python's OpenSSL: OpenSSL 3.0.12 24 Oct 2023
Python executable: /home/runner/work/urllib3/urllib3/.nox/test-pypy3-9/bin/python
Python version: 3.9.18 (9c4f8ef178b6, Jan 14 2024, 11:28:13)
[PyPy 7.3.15 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]
Platform: linux
sys.path: ['/home/runner/work/urllib3/urllib3', '/opt/hostedtoolcache/PyPy/3.9.18/x64/lib/pypy3.9', '/home/runner/work/urllib3/urllib3/.nox/test-pypy3-9/lib/pypy3.9/site-packages']
nox > python -c 'import sys; print(sys.implementation.name, sys.version_info.releaselevel)'
nox > python -m coverage run --parallel-mode -m pytest -v -ra --color=yes --tb=native --durations=10 --strict-config --strict-markers test/
============================= test session starts ==============================
platform linux -- Python 3.9.18[pypy-7.3.15-final], pytest-7.4.2, pluggy-1.3.0 -- /home/runner/work/urllib3/urllib3/.nox/test-pypy3-9/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/urllib3/urllib3
configfile: pyproject.toml
plugins: anyio-4.2.0, timeout-2.1.0
collecting ... collected 2085 items / 1 skipped
test/test_collections.py::TestLRUContainer::test_maxsize PASSED [ 0%]
...
test/contrib/test_pyopenssl.py::TestSSL::test_is_ipaddress_false[v2.sg.media-imdb.com1] PASSED [ 51%]
Error: The operation was canceled.
Environment
- Python: 3.9
What Broke
CI jobs were cancelled after exceeding the 30-minute timeout limit.
Why It Broke
The CI was timing out due to the PyPy version causing excessive test durations
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==2.2.0
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)
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)
Fix reference: https://github.com/urllib3/urllib3/pull/3308
First fixed release: 2.2.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not suitable if a different PyPy version is required for compatibility.
- 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
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.
- Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
- Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.
Version Compatibility Table
| Version | Status |
|---|---|
| 2.2.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.