Skip to content

fix(deploy): don't leave the 0% staging deployment behind when Cloudflare's status lags - #927

Open
hyfdev wants to merge 4 commits into
mainfrom
fix/cloudflare-staging-cleanup
Open

hyfdev wants to merge 4 commits into
mainfrom
fix/cloudflare-staging-cleanup

Conversation

@hyfdev

@hyfdev hyfdev commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

A deploy that stages the new version at 0% can stop right before activation and leave that staging deployment behind.

Every later deploy is then refused with "The existing Worker must have one deployed version receiving all traffic".

Now the deploy waits for Cloudflare's status to catch up, and removes its own staging deployment when a fresh read still shows it.

Before:

flowchart LR
  A["Stage previous@100, new@0"] --> B["Read status"]
  B -- "lags, shows previous@100" --> C["Stop as if another deploy happened"]
  C --> D["Staging left behind"]
  D --> E["Next deploy refused"]
Loading

After:

flowchart LR
  A["Stage previous@100, new@0"] --> B["Read status"]
  B -- "previous@100, new@0" --> F["Activate new@100"]
  B -- "same deployment as before staging" --> W["Wait, read again"]
  W --> B
  B -- "still lagging after the wait, or read failed" --> R{"Fresh read shows previous@100, new@0?"}
  R -- yes --> P["Redeploy previous@100, stop"]
  R -- no --> S["Stop, no write"]
  B -- "another deployment" --> S
Loading

A status that still shows the deployment ID from before staging counts as lagging, not as another deploy.

The deploy rereads it for up to about 5.5 minutes, on the schedule from #892.

Stops before activation now say whether Void removed its staging deployment, instead of claiming that triggers were restored.

A traffic-split stop after the upload no longer says that no version was uploaded.

When the fresh read can't confirm the staging deployment is Void's own, it stays in place and the next deploy is still refused.

Recovering from that in the next deploy is the issue's third proposal, and isn't part of this PR.

Part of #895.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-cloudflare-staging-cleanup-void-cloud.voidzero-docs.workers.dev (commit 1eb92ff)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://1ccf4caa-void-cloud.voidzero-docs.workers.dev 1eb92ff 2026-11-27T10:38:21.421Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://b625bfd4-void-cloud.voidzero-docs.workers.dev 3fe517d 2026-11-27T01:03:19.667Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://1e7b66ad-void-cloud.voidzero-docs.workers.dev e250b13 2026-11-26T09:43:04.134Z Visit the dashboard ↗

@hyfdev
hyfdev marked this pull request as ready for review November 26, 2026 13:20
Copilot AI balanced review requested due to automatic review settings November 26, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Woah, I ran into this a few times and could never repro. How did you find, repro and fix this?

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two issues:

  • If Cloudflare’s list catches up to Void’s staging deployment before it shows a newer rollback, the retry can send the candidate to 100%. After a failed status read, cleanup can instead send the previous version to 100%.
  • A newer deployment can have the same live@100%, candidate@0% split as a previous one, but we should probably save the deployment ID returned by the staging write and require an exact match before activation/cleanup.

@hyfdev

hyfdev commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Woah, I ran into this a few times and could never repro. How did you find, repro and fix this?

My agent suggested me don't answer this question becuase it'll show the fact I know nothing.

(I'm asking agents to use Void like a real person and it catch it.

@hyfdev

hyfdev commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Woah, I ran into this a few times and could never repro. How did you find, repro and fix this?

Agent talk: It came from #895: davidgustys's report pinned the stop to the single status read right after staging. I reproduced it in unit tests with a fake Cloudflare whose status still shows the previous deployment for a few reads after the staging write. I couldn't make Cloudflare itself lag on demand.


Both hold. Both are fixed, except one case that no read can rule out:

  • Void now saves the deployment ID that the staging write returns. It activates only when the next status read shows that exact deployment (does not change traffic when another Cloudflare deployment has the staged split).
  • Cleanup after a failed status read also needs a read that shows that deployment (skips staging cleanup when a failed status read is followed by a different deployment ID). So does the forced restore after a secret change (does not force a restore after another deployment reuses the staged split).
  • If the staging write returns no ID, the deploy stops before activation.
  • A rollback made after Void's last read, or not listed yet, can still be overwritten. Cloudflare's create-deployment API has no conditional write, and main's pre-activation read has the same gap.

@hyfdev

This comment has been minimized.

@hyfdev
hyfdev force-pushed the fix/cloudflare-staging-cleanup branch from 3fe517d to 1eb92ff Compare November 27, 2026 10:37
@hyfdev

hyfdev commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

#943 tells you how to clear the stuck 100%/0% pair once Void refuses a deploy.

This PR keeps Void from leaving that pair behind: when Cloudflare's status lags right after staging, the deploy waits for it to catch up and removes its own staging deployment if a fresh read still shows it.

Without this, every lagging status read still leaves the Worker stuck until someone clears it in the dashboard.

This branch has not been deployed

No deployments
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.

3 participants