Repository navigation
Conversation
Cloudflare's Worker version list can trail a write by minutes. Before the upload, wait while the list lacks the active version. After the upload, wait while the list still equals the baseline, on a schedule of about 5.5 minutes instead of 250 ms and 500 ms. Failed reads keep their two quick retries. Refs voidzero-dev#891
0froq
left a comment
There was a problem hiding this comment.
Looked into this and commented
| for ( | ||
| let attempt = 0; | ||
| previous.versionId !== null && | ||
| recent !== null && |
There was a problem hiding this comment.
The waits only continue while the read succeeded. A versions.list whose two pages disagree returns a non-zero status, which readRecentCloudflareVersionIds turns into null. That case gets 0 waits before the upload and only the 250/500 ms retries after it. Page 2 is only read above 10 versions, so this is the shape of the 20:08 inheritance-source-unavailable report in #891, not the stale-but-readable shape this fixes.
Not a regression, but "Fixes #891 for the version-list paths" would close the issue with that symptom unchanged. Either classify the page-overlap failure and retry it on this schedule, or narrow the claim.
| * Waits between reads of Cloudflare's Worker version list while it lags behind a write. | ||
| * Defaults to {@link STALE_VERSION_HISTORY_DELAYS_MS}. | ||
| */ | ||
| versionHistoryRetryDelaysMs?: ReadonlyArray<number>; |
There was a problem hiding this comment.
STALE_VERSION_HISTORY_DELAYS_MS is this option's documented default but is not exported from src/index.ts, so a caller that wants to extend the schedule has to copy the array. Add it to the ./version.ts export list next to activateCloudflareVersion.
Fixes #891 for the version-list paths. The
triggers-failedcase 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:
deployments statusreported. This read had no retry.Both use
STALE_VERSION_HISTORY_DELAYS_MS: 250 ms doubling up to 30 s, 17 waits, about 5.5 minutes in total. Each wait checksverifyUploader()and the first one reports progress. The schedule can be overridden with the newversionHistoryRetryDelaysMsoption.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
inheritance-source-changedbefore the upload,inheritance-source-unavailableafter it). Nothing is uploaded when the pre-upload wait runs out.stabilizeCloudflareVersionTriggersis untouched. The logs in Cloudflare deploy stops on a lagging Worker version list (inheritance-source-changed, triggers-failed) #891 do not show what its reads returned.Tests
packages/deploy-cloudflare/test/unit/version.test.ts:The new pre-upload tests and the changed stale-list case fail on
mainand pass here (5 failures without the change).Verified locally
Run in a shell with no
CLOUDFLARE_*,CF_*or wrangler variables (env | grep -ciE 'cloudflare|^CF_|wrangler'printed 0). The tests injectrunWrangler, so nocforwranglerprocess starts.vp test run packages/deploy-cloudflare/test/unit/version.test.ts: 231 passedvp check: no warnings, lint errors or type errorsvp run check:types: 35/35 successfulvp run test:all: 92 of 93 tasks passed. The one failing task wasplatform-api-integration-threads, 12 tests, because Playwright's Chromium was not installed. Afterplaywright install chromiumthe six failing files passed (204 tests).