[wrangler] Attempts to reduce remote e2e test flakiness#12896
Open
petebacondarwin wants to merge 11 commits intomainfrom
Open
[wrangler] Attempts to reduce remote e2e test flakiness#12896petebacondarwin wants to merge 11 commits intomainfrom
petebacondarwin wants to merge 11 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 6413596 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
bef408f to
3de2809
Compare
vi.waitFor/vi.waitUntil to wait for logger output in e2e testsvi.waitFor/vi.waitUntil to wait for things in e2e tests
1e6a215 to
ea1dfd6
Compare
petebacondarwin
commented
Mar 16, 2026
ea1dfd6 to
0471f8c
Compare
vi.waitFor/vi.waitUntil to wait for things in e2e tests0471f8c to
e1a9b31
Compare
Contributor
|
✅ All changesets look good |
gpanders
approved these changes
Mar 17, 2026
a6c37fc to
961354c
Compare
- Extract shared waitFor() and waitForLong() helpers wrapping vi.waitFor() with tuned defaults - waitFor(): 100ms interval, 5s timeout — for polling synchronous state (e.g. console output) - waitForLong(): 500ms interval, 10s timeout — for polling HTTP endpoints - Add ESLint rule to enforce using these helpers instead of bare vi.waitFor() in e2e tests - Migrate all e2e tests to use the shared helpers
Wrap createPreviewSession() and createWorkerPreview() in retryOnAPIFailure so transient 5xx errors are retried automatically (up to 3 attempts with linear backoff). Also add an optional abortSignal parameter to retryOnAPIFailure so backoff delays can be cancelled immediately when a new bundle arrives.
- startWorker: use waitForLong (10s) instead of waitFor (5s) for remote reload polling, matching the convention for HTTP endpoint polling - start-worker-remote-bindings: increase beforeAll deploy timeout from 35s to 60s for slow Windows CI - dev.test Workers+Assets: increase waitForReady/waitForReload from 15s to 30s since remote mode involves session creation + asset upload + bundle upload to edge-preview - create-worker-preview: add 30s per-request timeout via AbortSignal.any so a hung Cloudflare API response doesn't block the reload indefinitely
Reuse pre-deployed workers instead of deploying fresh ones on every test run. The new ensureWorkerDeployed() helper checks whether a worker is already live before deploying, and the preserve-e2e- prefix keeps the workers excluded from periodic cleanup.
Thread the abort signal through to the fetchResult call inside getWorkersDevSubdomain so it gets the same withTimeout protection as the other API calls in createPreviewSession.
The backoff computation backoff + (MAX_ATTEMPTS - attempts) * 1000 was off-by-one: the computed delay was passed to the next recursive call but that call would throw before ever sleeping on it. Replace with a simple backoff + 1000 so the first retry is immediate (0ms) and the second waits 1000ms, matching the documented intent.
dfb8330 to
215ecda
Compare
A timed-out API request (DOMException with name TimeoutError) is a transient failure and should be retried, just like 5xx errors. User- initiated aborts (AbortError) are still propagated immediately.
penalosa
approved these changes
Mar 19, 2026
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.
Several changes to reduce flakiness in the wrangler remote-binding and dev e2e tests:
Consistent
waitFor/waitForLonghelperswaitFor()andwaitForLong()helpers that wrapvi.waitFor()with tuned defaultswaitFor(): 100ms interval, 5s timeout — for polling synchronous state (e.g. console output)waitForLong(): 500ms interval, 10s timeout — for polling HTTP endpointsvi.waitFor()in e2e testsRetry transient API failures in remote preview
createPreviewSession()andcreateWorkerPreview()inretryOnAPIFailureso transient 5xx errors are retried automatically (up to 3 attempts with linear backoff)abortSignalparameter toretryOnAPIFailureso backoff delays can be cancelled immediately when a new bundle arrivesIncrease e2e timeouts for remote preview and add per-request API timeout
startWorker: usewaitForLong(10s) instead ofwaitFor(5s) for remote reload polling, matching the convention for HTTP endpoint pollingstart-worker-remote-bindings: increasebeforeAlldeploy timeout from 35s to 60s for slow Windows CIdev.testWorkers+Assets: increasewaitForReady/waitForReloadfrom 15s to 30s since remote mode involves session creation + asset upload + bundle upload to edge-previewcreate-worker-preview: add 30s per-request timeout viaAbortSignal.anyso a hung Cloudflare API response doesn't block the reload indefinitelyUse shared
preserve-e2e-*workers for remote-binding testsensureWorkerDeployed()helper toWranglerE2ETestHelperthat checks whether a worker is already live (by fetching itsdevprod-testing7928.workers.devURL) and only deploys if it returns 404dev-remote-bindings.test.ts,start-worker-remote-bindings.test.ts, andremote-bindings-api.test.tsto use fixedpreserve-e2e-wrangler-remote-worker/preserve-e2e-wrangler-remote-worker-altnames instead of deploying fresh workers with random names on every runpreserve-e2e-prefixA picture of a cute animal (not mandatory, but encouraged)