Repository navigation
fix(deploy): Wait until Cloudflare serves a version before deploying it - #2438
Merged
Merged
Conversation
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]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…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
approved these changes
Nov 21, 2026
7 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()inscripts/cloudflare-deployment.mjsis 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]