Skip to content

Commit 0980807

Browse files
Brooooooklynclaude
andcommitted
test(deploy): widen the live-worker 200 poll for fresh workers.dev propagation
The env plumbing is fixed and the live deploy now runs in CI, but the first run failed the 200 check: a brand-new *.workers.dev hostname (unique per run) needs its route to propagate globally before the first request succeeds, and that window is longer from a CI runner than a dev machine (a solid 30s of 404s). Poll up to ~2 min, and on a persistent non-200 report the URL plus whether the workers.dev route is enabled — to tell slow propagation from a route that never went live. Remove the temporary env-location probes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019wnwcxjavdb2xys8XGZora
1 parent c0b0aae commit 0980807

3 files changed

Lines changed: 36 additions & 19 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ jobs:
5454
- run: vp exec playwright install chromium
5555
if: ${{ contains(matrix.os, 'windows') }}
5656

57-
# TEMP diagnostic (remove after): confirm the step shell has all three vars before `vp run`.
58-
- name: e2e env in step shell (debug)
59-
run: node -e "console.log('[[STEP]] token', (process.env.VOID_E2E_CF_TOKEN||'').length, 'account', (process.env.VOID_E2E_CF_ACCOUNT_ID||'').length, 'runid', (process.env.VOID_E2E_RUN_ID||'').length)"
60-
6157
- run: vp run test:all
6258

6359
done:

‎packages/void/test/e2e/cloudflare-deploy-live.test.ts‎

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,15 @@ function extractWorkerUrl(output: string): string | undefined {
248248
}
249249

250250
/**
251-
* Poll the live worker until it serves a 200 (edge propagation can lag the deploy by a few seconds,
252-
* and a freshly-deployed route can transiently 404 or 5xx before it is live). Retries on ANY
251+
* Poll the live worker until it serves a 200. A BRAND-NEW `*.workers.dev` hostname (every run uses a
252+
* unique worker name) needs the route to propagate globally before the first request succeeds, and
253+
* that window is materially longer from a CI runner's network path than from a dev machine — a run
254+
* observed a solid 30s of 404s before the route went live. So poll generously (~2 min). Retries on ANY
253255
* non-200 — not just 5xx — so a propagation-window 404 is not mistaken for the final answer. On
254-
* exhaustion returns the LAST response so the caller's status assertion reports the real final
255-
* status; throws only when every attempt was a network error (no response at all).
256+
* exhaustion returns the LAST response so the caller's status assertion reports the real final status;
257+
* throws only when every attempt was a network error (no response at all).
256258
*/
257-
async function fetchWithRetry(url: string, attempts = 10): Promise<Response> {
259+
async function fetchWithRetry(url: string, attempts = 40, delayMs = 3000): Promise<Response> {
258260
let lastResponse: Response | undefined;
259261
let lastError: unknown;
260262
for (let i = 0; i < attempts; i++) {
@@ -269,14 +271,34 @@ async function fetchWithRetry(url: string, attempts = 10): Promise<Response> {
269271
lastError = error;
270272
lastResponse = undefined;
271273
}
272-
await new Promise((resolve) => setTimeout(resolve, 3000));
274+
if (i < attempts - 1) {
275+
await new Promise((resolve) => setTimeout(resolve, delayMs));
276+
}
273277
}
274278
if (lastResponse) {
275279
return lastResponse;
276280
}
277281
throw lastError ?? new Error(`worker at ${url} never answered`);
278282
}
279283

284+
/**
285+
* Whether the deployed worker has its `*.workers.dev` route enabled, for diagnosing a persistent 404.
286+
* A propagation-window 404 has the route enabled (just not live yet); a route that is DISABLED 404s
287+
* forever. Best-effort — returns a short human string, never throws.
288+
*/
289+
async function workersDevEnabled(): Promise<string> {
290+
try {
291+
const res = await fetch(
292+
`https://api.cloudflare.com/client/v4/accounts/${cfAccountId()}/workers/scripts/${WORKER_NAME}/subdomain`,
293+
{ headers: { Authorization: `Bearer ${cfToken()}` } },
294+
);
295+
const body = (await res.json().catch(() => ({}))) as { result?: unknown };
296+
return `workers.dev subdomain endpoint ${res.status}: ${JSON.stringify(body.result ?? body)}`;
297+
} catch (error) {
298+
return `workers.dev subdomain check errored: ${String(error)}`;
299+
}
300+
}
301+
280302
describe('void deploy --backend cloudflare (live account)', () => {
281303
beforeAll(async () => {
282304
// Gate at execution time (see the credential note): when the token/account are absent the suite is
@@ -482,7 +504,12 @@ describe('void deploy --backend cloudflare (live account)', () => {
482504
ctx.skip(!e2eEnabled(), NO_CREDS_NOTE);
483505
const base = extractWorkerUrl(deployOutput);
484506
expect(base, deployOutput).toBeDefined();
485-
const res = await fetchWithRetry(`${base!.replace(/\/$/, '')}/api/hello`);
486-
expect(res.status).toBe(200);
487-
});
507+
const url = `${base!.replace(/\/$/, '')}/api/hello`;
508+
const res = await fetchWithRetry(url);
509+
// On a persistent non-200, report the URL + whether the workers.dev route is even enabled, to
510+
// tell a slow-propagation 404 (route enabled) from a route that never went live (disabled).
511+
const diagnostic =
512+
res.status === 200 ? '' : ` — GET ${url} → ${res.status}; ${await workersDevEnabled()}`;
513+
expect(res.status, `worker ${WORKER_NAME}${diagnostic}`).toBe(200);
514+
}, 200_000);
488515
});

‎vite.config.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ const e2eWorkerEnv = {
1313
VOID_E2E_CF_ACCOUNT_ID: process.env.VOID_E2E_CF_ACCOUNT_ID ?? '',
1414
VOID_E2E_RUN_ID: process.env.VOID_E2E_RUN_ID ?? '',
1515
};
16-
// TEMP diagnostic (remove after): does the vitest MAIN config process have the vars? If account is 0
17-
// here while the CI step shell had 32, the env is filtered before vitest (in `vp run`), so test.env
18-
// cannot recover it.
19-
console.error(
20-
`[[CFG]] token=${(process.env.VOID_E2E_CF_TOKEN ?? '').length} account=${(process.env.VOID_E2E_CF_ACCOUNT_ID ?? '').length} runid=${(process.env.VOID_E2E_RUN_ID ?? '').length}`,
21-
);
2216

2317
// Windows CI runners are 2-3x slower for builds and server startup.
2418
const ciTimeoutScale = process.platform === 'win32' ? 3 : 1;

0 commit comments

Comments
 (0)