Skip to content

fix(deploy): Wait until Cloudflare serves a version before deploying it - #2438

Merged
dcramer merged 2 commits into
mainfrom
fix/deploy-wait-for-readable-version
Nov 21, 2026
Merged

dcramer merged 2 commits into
mainfrom
fix/deploy-wait-for-readable-version

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Production deploys keep stopping at the stage step with Cloudflare error 100146 ("The requested Worker version could not be found"), for example in 43952070458 and 44604518080. Prod stays on the old version, but someone has to restart the deploy.

Wrangler's versions deploy fetches each version by ID before it creates the deployment (source). Stage starts a few seconds after upload, and in that window Cloudflare can still answer 404 for the new version.

deployVersions() in scripts/cloudflare-deployment.mjs is now the only way to move traffic. It waits until Cloudflare returns every version by ID three times in a row, then deploys. 404, 429, 5xx, and network errors mean "not yet"; auth and other errors fail at once. The wait gives up after 60 seconds, before any traffic moves, so a version that never appears fails the job instead of holding the deploy queue. Stage, promote, recovery, and the Docs MCP deploy (which had the same race) all use it. Workflows that call Wrangler's deploy directly are rejected, and AGENTS.md records that rule next to what enforces it.

The 60-second limit comes from Cloudflare history: production stages from Nov 10 to Nov 19 ran 3.1 to 5.9 seconds after upload, and the two failures hit the 404 at about 3.6 and 4.6 seconds. Some stages that ran earlier than that succeeded, so the lag looks like lagging replicas rather than a fixed delay. That is why one successful read is not enough.

via @dcramer.

--

View Session [Sentry]

wrangler versions deploy reads each version by ID before it creates the
deployment. A few seconds after versions upload, Cloudflare can still
answer 404 (code 100146) for the new version, so the stage step failed
in runs 43952070458 and 44604518080 and the rollout stopped.

Route every traffic change, including Docs MCP, through deployVersions(),
which waits for three successful reads in a row first. A test fails any
workflow that calls wrangler versions deploy directly.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 19, 2026 8:59pm UTC
sentry-local Ready Ready Preview Nov 19, 2026 8:59pm UTC

Request Review

…ent errors

The wait for a readable version gave up after 15 reads, and any 5xx,
429, or network error on a read failed the deploy at once. Use a
60-second deadline instead. Treat 404, 429, 5xx, and network errors as
not ready yet, and fail at once on anything else, such as auth errors.

The 50 production stages from Nov 10 to Nov 19 ran 3.1 to 5.9 seconds
after their upload. The two 100146 failures came 3.6 and about 4.6
seconds after upload, so 60 seconds gives roughly ten times the
observed lag while still failing before any traffic moves.

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer merged commit acbdba9 into main Nov 21, 2026
42 checks passed
@dcramer
dcramer deleted the fix/deploy-wait-for-readable-version branch November 21, 2026 22:44

This branch was successfully deployed

2 active deployments
Preview – sentry-local — 0ff875e8 Deployed Nov 19, 2026 by vercel[bot]
Preview – cli — 0ff875e8 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant