Skip to content

Retry stale Durable Object binding verification reads after Worker upload - #880

Merged
cpojer merged 2 commits into
voidzero-dev:mainfrom
iPLAYCAFE-dev:fix/retry-do-binding-verification
Nov 19, 2026
Merged

cpojer merged 2 commits into
voidzero-dev:mainfrom
iPLAYCAFE-dev:fix/retry-do-binding-verification

Conversation

@iPLAYCAFE-dev

Copy link
Copy Markdown
Contributor

Fixes transient Application custom Durable Object binding could not be verified. errors right after uploadDeploymentWorker uploads a Worker carrying custom Durable Object bindings.

Summary

  • Updates verifyManagedDurableObjectApplicationBindings in platform/packages/api/src/provisioning/durable-objects.ts to retry stale/empty readBindings results across bounded delays ([250, 500, 1_000] ms by default, matching the deployment readback retry pattern from platform upgrade: post-activation lineage check fails on a stale deployments read ("changed concurrently after activation") #868) before failing.
  • Keeps immediate success on 1st read (0 extra API calls when consistent) and allows overriding delaysMs in tests.
  • Adds unit tests in platform/packages/api/test/unit/deploy-durable-objects.test.ts covering immediate match, recovery after a stale/empty initial read, and failure when bindings never match.

@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.

👍 Thank you.

@cpojer
cpojer merged commit 9b864fc into voidzero-dev:main Nov 19, 2026
2 checks passed
Brooooooklyn added a commit that referenced this pull request Nov 25, 2026
#892)

Fixes #891 for the version-list paths. The `triggers-failed` case in the
issue is not changed here.

## Change

Cloudflare's Worker version list can trail a write by minutes. The
deploy now waits for it in the two places where the expected state is
known:

- Before the upload: while the list does not contain the active version
that `deployments status` reported. This read had no retry.
- After the upload: while the list is still identical to the pre-upload
baseline, or is an older snapshot of it (it ends below the baseline and
agrees with it on every shared version number). The existing retry
stopped after 250 ms and 500 ms.
- Both places: when `versions.list` fails because its two pages
disagreed ("The Cloudflare Worker version history changed during
inspection"). The runner now marks that failure as
`version-history-changed`, and it is retried on the same schedule. Page
2 is read only above 10 versions, so this is the
`inheritance-source-unavailable` shape in the second report on #891.

After either wait, production is read again: before the upload, and
before the candidate receipt is saved. If a rollback or another deploy
changed it during the wait, the deploy stops with `deployment-changed`
and saves no receipt, so the next deploy does not find a receipt with
the wrong parent. Production is read again only after a wait for a
lagging list, not after the quick retries of a failed read. If that read
fails after the upload, the deploy stops with `status-failed`
("uploaded, but Cloudflare deployment status could not be verified
before activation"); a handoff deploy keeps its verified receipt so the
retry can use it.

These waits use `STALE_VERSION_HISTORY_DELAYS_MS`: 250 ms doubling up to
30 s, 17 waits, about 5.5 minutes in total. Each wait checks
`verifyUploader()`, and the first wait for a lagging list reports
progress. The schedule can be overridden with the new
`versionHistoryRetryDelaysMs` option. `STALE_VERSION_HISTORY_DELAYS_MS`
is exported from the package entry.

Why this length: in the runs in #891 a new version was still missing 52
s after creation and was listed within about 4.5 minutes. #880 and #868
retried for a second or less, which does not reach that. If maintainers
want a shorter cap, change the constant.

## What does not change

- A list that never catches up, or whose pages keep disagreeing, fails
with `inheritance-source-unavailable`, before or after the upload.
Nothing is uploaded when the pre-upload wait runs out, on handoff and
direct deploys alike. (Before, a direct deploy could go on to pin the
active secrets and upload.)
- Any other mismatch (a concurrent version, a different history) still
fails at once, with no wait.
- Any other failed read (not stale, not page overlap) keeps its
behavior: it fails at once before the upload and gets two quick retries
after it.
- A rollback to a version older than the list's page of 10 never appears
in the list, so it does not wait. Before waiting, the active version's
`number` is read with `versions.view`; the wait happens only when that
number is not below the list's lowest number. If the number cannot be
read (failed or thrown read, or no integer `number`; the API marks the
field optional), it is read again on the next wait, and the deploy keeps
waiting while it stays unreadable, since a version the list trails may
not be readable yet either.
- `void link` keeps a saved candidate receipt only when its parent is
still the active version.
- `stabilizeCloudflareVersionTriggers` is untouched. The logs in #891 do
not show what its reads returned.

## Tests

`packages/deploy-cloudflare/test/unit/version.test.ts`:

- Pre-upload: active version present (no wait), list recovers after two
stale reads, list never catches up (no upload), uploader changes during
the wait.
- Page overlap: retried and recovers, retried until the schedule runs
out, and a different failure does not wait, before and after the upload.
The runner test in `packages/void/test/unit/cf-version-runner.test.ts`
checks the `version-history-changed` marker.
- Post-upload: the existing stale-list cases now expect the full
schedule; failed reads still expect two waits. An older snapshot waits
like a stale list, and a list that names another version at a shared
number still fails at once. A quick retry after a failed read adds no
production read, and a wait that starts after a failed read still
reports progress.
- The default schedule is used, is between 5 and 6 minutes, and reports
progress.
- A rollback during the wait, before and after the upload: the deploy
stops with `deployment-changed`, and `recordVerifiedCandidate` is never
called.
- An active version older than ten listed versions does not wait. A
failed, thrown or unnumbered `versions.view` still waits the whole
schedule.

The new pre-upload tests and the changed stale-list case fail on `main`
and pass here (5 failures without the change; measured before the
page-overlap commit).

## Verified locally

Run in a shell with no `CLOUDFLARE_*`, `CF_*` or wrangler variables
(`env | grep -ciE 'cloudflare|^CF_|wrangler'` printed 0). The tests
inject `runWrangler`, so no `cf` or `wrangler` process starts.

- `vp test run packages/deploy-cloudflare/test/unit/version.test.ts`:
237 passed after the page-overlap commit (231 before)
- After the page-overlap commit, `vp check`, `vp run check:types`
(35/35) and `vp test run packages/deploy-cloudflare packages/deploy-core
packages/void/test/unit` were re-run: 10069 passed, 17 failed. The 17
are `init.test.ts` (16) and `nitro.test.ts` (1), which also fail on the
commit before this one in the same shell.
- `vp check`: no warnings, lint errors or type errors
- `vp run check:types`: 35/35 successful
- `vp run test:all`: 92 of 93 tasks passed. The one failing task was
`platform-api-integration-threads`, 12 tests, because Playwright's
Chromium was not installed. After `playwright install chromium` the six
failing files passed (204 tests).
- No user-facing documentation changes: this is an internal retry
window.

---------

Co-authored-by: Christoph Nakazawa <cnakazawa@cloudflare.com>
Co-authored-by: LongYinan <github@lyn.one>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants