Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
2070355
[wrangler] use consistent waitFor/waitForLong helpers in e2e tests
petebacondarwin Mar 16, 2026
b92d004
Add retries to realish preview session and worker upload API calls
petebacondarwin Mar 17, 2026
89ccae8
Increase e2e timeouts for remote preview and add per-request API timeout
petebacondarwin Mar 17, 2026
808e353
fixup
petebacondarwin Mar 18, 2026
f8eb06c
Use shared preserve-e2e workers for remote-binding e2e tests
petebacondarwin Mar 18, 2026
943161d
Add timeout protection to getWorkersDevSubdomain in createPreviewSession
petebacondarwin Mar 18, 2026
18f9232
Add changeset for remote preview retry and timeout changes
petebacondarwin Mar 18, 2026
e7adf6a
Fix retry backoff formula — retries were always firing with 0ms delay
petebacondarwin Mar 18, 2026
2ff5e37
fix formatting and linting issues
petebacondarwin Mar 18, 2026
13c0f68
fix missing import
petebacondarwin Mar 18, 2026
2acf8e3
Retry on TimeoutError from per-request AbortSignal.timeout()
petebacondarwin Mar 18, 2026
b23eb23
Fix EADDRINUSE flakes by eliminating TOCTOU port races in e2e tests
petebacondarwin Mar 19, 2026
fe9e10a
Use waitForLong for error-log tests that depend on remote API validation
petebacondarwin Mar 19, 2026
461d753
Fix TOCTOU port race in remote proxy session and use waitForLong for …
petebacondarwin Mar 19, 2026
0ab6e78
clarify minimum version of Node for Wrangler
petebacondarwin Mar 19, 2026
f38b783
clarify minimum version of Node for Wrangler
petebacondarwin Mar 19, 2026
5298aa9
Make workers.dev domain configurable via E2E_ACCOUNT_WORKERS_DEV_DOMAIN
petebacondarwin Mar 19, 2026
91deef0
Increase vite-plugin waitForReady timeout from 20s to 30s
petebacondarwin Mar 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/calm-pens-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

fix: Add retry and timeout protection to remote preview API calls

Remote preview sessions (`wrangler dev --remote`) now automatically retry transient 5xx API errors (up to 3 attempts with linear backoff) and enforce a 30-second per-request timeout. Previously, a single hung or failed API response during session creation or worker upload could block the dev session reload indefinitely.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import type { DispatchFetch, Response } from "miniflare";

type Fetcher = { fetch: DispatchFetch };

const workersDomain =
process.env.E2E_ACCOUNT_WORKERS_DEV_DOMAIN ??
"devprod-testing7928.workers.dev";
const auth = getAuthenticatedEnv();
const execOptions = {
encoding: "utf8",
Expand All @@ -35,8 +38,7 @@ if (auth) {
let remoteKvId: string;

beforeAll(async () => {
const deployedUrl =
"https://preserve-e2e-get-platform-proxy-remote.devprod-testing7928.workers.dev/";
const deployedUrl = `https://preserve-e2e-get-platform-proxy-remote.${workersDomain}/`;

try {
assert((await fetch(deployedUrl)).status !== 404);
Expand All @@ -54,8 +56,7 @@ if (auth) {
);
}

const stagingDeployedUrl =
"https://preserve-e2e-get-platform-proxy-remote-staging.devprod-testing7928.workers.dev/";
const stagingDeployedUrl = `https://preserve-e2e-get-platform-proxy-remote-staging.${workersDomain}/`;
try {
assert((await fetch(stagingDeployedUrl)).status !== 404);
} catch {
Expand Down
5 changes: 4 additions & 1 deletion packages/create-cloudflare/e2e/tests/cli/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { recreateLogFolder } from "../../helpers/log-stream";
import { runC3 } from "../../helpers/run-c3";

const { name: pm } = detectPackageManager();
const workersDomain =
process.env.E2E_ACCOUNT_WORKERS_DEV_DOMAIN ??
"devprod-testing7928.workers.dev";

describe("Create Cloudflare CLI", () => {
beforeAll((ctx) => {
Expand Down Expand Up @@ -497,7 +500,7 @@ describe("Create Cloudflare CLI", () => {
if (
(
await fetch(
"https://existing-script-test-do-not-delete.devprod-testing7928.workers.dev/"
`https://existing-script-test-do-not-delete.${workersDomain}/`
)
).status === 404
) {
Expand Down
4 changes: 3 additions & 1 deletion packages/vite-plugin-cloudflare/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ export async function fetchJson(url: string, info?: RequestInit) {
export async function waitForReady(proc: Process) {
const match = await vi.waitUntil(
() => proc.stdout.match(/Local:\s+(http:\/\/localhost:\d+)/),
{ interval: 100, timeout: 20_000 }
// buildAndPreview does a full build before starting the server,
// so allow more time than the default.
{ interval: 100, timeout: 30_000 }
);
return match[1];
}
Expand Down
12 changes: 6 additions & 6 deletions packages/vite-plugin-cloudflare/e2e/remote-bindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {

const commands = ["dev", "buildAndPreview"] as const;
const isWindows = process.platform === "win32";
const workersDomain =
process.env.E2E_ACCOUNT_WORKERS_DEV_DOMAIN ??
"devprod-testing7928.workers.dev";

// Remote bindings tests are skipped on Windows due to slow/unreliable remote proxy
// session initialization times in CI, which causes intermittent timeout failures.
Expand All @@ -38,11 +41,8 @@ if (isWindows) {
beforeAll(async () => {
try {
assert(
(
await fetch(
"https://preserve-e2e-vite-remote.devprod-testing7928.workers.dev/"
)
).status !== 404
(await fetch(`https://preserve-e2e-vite-remote.${workersDomain}/`))
.status !== 404
);
} catch {
runCommand(`npx wrangler deploy`, `${projectPath}/remote-worker`);
Expand All @@ -51,7 +51,7 @@ if (isWindows) {
assert(
(
await fetch(
"https://preserve-e2e-vite-remote-alt.devprod-testing7928.workers.dev/"
`https://preserve-e2e-vite-remote-alt.${workersDomain}/`
)
).status !== 404
);
Expand Down
23 changes: 20 additions & 3 deletions packages/wrangler/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,33 @@ pnpm test:e2e:wrangler -- -u --bail=1
### Cloudflare Credentials

Cloudflare credentials are provided to the tests by setting `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN`.
If you don't provide these then only the local e2e tests are executed.

- If you don't provide these then only the local e2e tests are executed.
- If you don't provide the "DevProd Testing" Cloudflare account (as `CLOUDFLARE_ACCOUNT_ID=8d783f274e1f82dc46744c297b015a2f`), tests that require that specific account are not executed.
#### Running against the CI account

To fully run the tests you should generate an API token for the "DevProd Testing" account:
The default configuration targets the "DevProd Testing" account. To fully run the tests, generate an API token for that account:

```zsh
CLOUDFLARE_ACCOUNT_ID=8d783f274e1f82dc46744c297b015a2f CLOUDFLARE_API_TOKEN=<cloudflare-testing-api-token> pnpm test:e2e:wrangler
```

#### Running against your own account

You can run the e2e tests against any Cloudflare account. Some tests rely on
pre-deployed `preserve-e2e-*` workers whose URL includes the account's
`workers.dev` subdomain. Set `E2E_ACCOUNT_WORKERS_DEV_DOMAIN` so these tests
can locate (and, on first run, deploy) those workers on your account:

```zsh
CLOUDFLARE_ACCOUNT_ID=<your-account-id> \
CLOUDFLARE_API_TOKEN=<your-api-token> \
E2E_ACCOUNT_WORKERS_DEV_DOMAIN=<your-subdomain>.workers.dev \
pnpm test:e2e:wrangler
```

> You can find your subdomain in the Cloudflare dashboard under **Workers & Pages**.
> It defaults to `devprod-testing7928.workers.dev` (the CI account).

### Focusing on a single e2e test file

If you want to run a subset of tests (e.g. just one) while retaining the turborepo cache for the builds of the dependencies, you can provide the list of test files via the `WRANGLER_E2E_TEST_FILE` environment variable.
Expand Down
Loading
Loading