Skip to content

Wait for the new Runtime version after a hosted deployment - #376

Merged
tnkuehne merged 1 commit into
mainfrom
runtime-version-propagation
Nov 24, 2026
Merged

tnkuehne merged 1 commit into
mainfrom
runtime-version-propagation

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

A new Worker version takes a few seconds to reach every Cloudflare location. deploy-hosted read the Runtime version once, right after wrangler deploy returned, and failed with "The requested Runtime version is not active" when that request still reached the previous version. The Runtime was then already on the new version, but the control plane had not been deployed, and a rerun was needed.

The check now repeats every two seconds for up to a minute and fails only if the new version still does not answer.

Testing

  • pnpm check
  • tests/cloudflare/hosted-installation.test.ts: the wait resolves once the new version answers and fails after its attempts when it never does.

RetriggerView in GreptileConfidence Score: 3/5

Fix the wait before merging so transient read errors can recover and slow reads cannot hold deployment locks past the promised minute.

Findings

  1. P1 A brief error stops deployment ▶
  2. P1 Wait can exceed one minute ▶

Summary

deploy-hosted now polls for the requested Runtime version before continuing to the control-plane deploy.

  • Hosted deployments wait for the new Runtime version to answer.

Reviews (1) · Last reviewed commit: "Wait for the new Runtime version after a..." · Reviewed by Greptile

A new Worker version takes a few seconds to reach every Cloudflare
location. The hosted deployment checked the Runtime version once, right
after `wrangler deploy`, and failed when that request still reached the
previous version, leaving the control plane undeployed. It now checks
again every two seconds for up to a minute.
{ attempts = 30, interval = 2_000 } = {},
) => {
for (let attempt = 1; ; attempt++) {
if ((await read()) === version) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 A brief error stops deployment

If Cloudflare returns a temporary HTTP 503 after wrangler deploy, the version check throws and skips the remaining attempts. The control plane never deploys, even if the next check would reach the new Runtime. Retry temporary read errors and test that the wait succeeds when the next check returns the expected version.

Comment on lines +83 to +89
{ attempts = 30, interval = 2_000 } = {},
) => {
for (let attempt = 1; ; attempt++) {
if ((await read()) === version) return;

if (attempt >= attempts) throw new Error("The requested Runtime version is not active");
await new Promise((resolve) => setTimeout(resolve, interval));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Wait can exceed one minute

waitForRuntimeVersion counts checks, not time. The pauses alone can take 58 seconds. If 30 checks each take a second and return the old version, the wait takes about 88 seconds, with database locks blocking app provisioning and Runtime updates the whole time. Use one deadline that also limits how long the code waits for a check to finish.

@tnkuehne
tnkuehne merged commit e9f39fd into main Nov 24, 2026
16 checks passed
@tnkuehne
tnkuehne deleted the runtime-version-propagation branch November 24, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant