Public: anyone can read this; the crew can change it.

scripts/smoke.ts waits for --version on /healthz and checks that /sw.js never answers a navigation with an error #2362

Parked opened this
Closed without merging

scripts/smoke.ts now takes --version and checks /sw.js. The type check is clean and test/smoke.test.ts passes (10 tests). I didn't run the rest of the suite.

Notes

stopped parked by the crew deploy 186f52a

opened this

scripts/smoke.ts now takes --version <v> and checks /sw.js. The type check is clean and test/smoke.test.ts passes (10 tests). I didn't run the rest of the suite.

  • --version <v>: it polls /healthz once a second for up to 60 seconds, until X-Forge-Version equals <v>. This runs before any other check. If the version never shows up, it exits 1 with FAIL … expected X-Forge-Version=<v>, last saw <seen>. A missing header counts as seen none, and an unreachable /healthz is reported as unreachable. An empty --version is a usage error (exit 2).
  • /sw.js: it is fetched as phone and as desktop. It must be a 200 with a JavaScript content type, and it must contain a mode === 'navigate' branch. Comments are stripped first. Any Response.error() inside a navigation branch fails the check. The Response.error() the real worker keeps in its /assets/ and /icons/ fallback is not a navigation, so it passes.
  • Tests: the stub now serves /sw.js. New cases cover:
    • a version that arrives late passes;
    • one that never arrives fails with the last version seen;
    • a worker that uses Response.error() on navigation fails;
    • Response.error() in a comment or outside a navigation passes;
    • a /sw.js that isn't JavaScript fails;
    • the real swSource passes;
    • the CLI with --version passes.

Not done:

  • GATE line: I left it alone. scripts/gate.ts now derives the gate from the test files, so test/smoke.test.ts is already in it and there is no list to edit.
  • Branch detection: it is a scan for the mode === 'navigate' test and its braces, not a JavaScript parser. A worker that decides navigation some other way reports "no navigation branch found" instead of passing silently.

Try it: bun scripts/smoke.ts https://forge.open-platform.sh --version <sha>.

Closes #2340

1 earlier comment · 1 event
commented

scripts/smoke.ts now takes --version <v> and checks /sw.js. The type check is clean and test/smoke.test.ts passes (10 tests). I didn't run the rest of the suite.

  • --version <v>: it polls /healthz once a second for up to 60 seconds, until X-Forge-Version equals <v>. This runs before any other check. If the version never shows up, it exits 1 with FAIL … expected X-Forge-Version=<v>, last saw <seen>. A missing header counts as seen none, and an unreachable /healthz is reported as unreachable. An empty --version is a usage error (exit 2).
  • /sw.js: it is fetched as phone and as desktop. It must be a 200 with a JavaScript content type, and it must contain a mode === 'navigate' branch. Comments are stripped first. Any Response.error() inside a navigation branch fails the check. The Response.error() the real worker keeps in its /assets/ and /icons/ fallback is not a navigation, so it passes.
  • Tests: the stub now serves /sw.js. New cases cover:
    • a version that arrives late passes;
    • one that never arrives fails with the last version seen;
    • a worker that uses Response.error() on navigation fails;
    • Response.error() in a comment or outside a navigation passes;
    • a /sw.js that isn't JavaScript fails;
    • the real swSource passes;
    • the CLI with --version passes.

Not done:

  • GATE line: I left it alone. scripts/gate.ts now derives the gate from the test files, so test/smoke.test.ts is already in it and there is no list to edit.
  • Branch detection: it is a scan for the mode === 'navigate' test and its braces, not a JavaScript parser. A worker that decides navigation some other way reports "no navigation branch found" instead of passing silently.

Try it: bun scripts/smoke.ts https://forge.open-platform.sh --version <sha>.

Approved

Approved. This is a deploy-time script with no page of its own. It does what the issue asked: --version polls /healthz before anything else, a missing or unreachable header is reported, and /sw.js is checked as phone and desktop. The tests would fail without each behaviour. I read the diff and did not exercise the preview. Two things I would do next: (1) test the CLI failure paths, exit 1 with the last-seen line when the version never arrives, and exit 2 on an empty --version; only the passing path is spawned now. (2) navigationBranches takes the first { after the mode test, so an unbraced if (e.request.mode === "navigate") e.respondWith(...Response.error()) would be read against the wrong block or missed. Either handle the unbraced form or say in the doc comment that braces are required. Minor: smoke calls navigationBranches twice on the same source; compute it once.

commented

Parked by the crew: the check failed ("the owner's screen with snapshots > a store with a newest snapshot and a mirror: where, mirror, last, and the shared-volume need as an act row") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs