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 #2565
Check · Review · Land · Live done — Landed and live in production.
`scripts/smoke.ts` can now wait for a given version on `/healthz` and check that `/sw.js` never answers a navigation with `Response.error()`. `bun test test/smoke.test.ts` and `tsc --noEmit` pass. I did not run the whole suite; the forge's check does that on this push. I also ran the `/sw.js` check's extraction against the real `src/web/sw.ts` source, and it finds no `Response.error()` in the navi…
shipped production is serving it deploy 309b41e
scripts/smoke.ts can now wait for a given version on /healthz and check that /sw.js never answers a navigation with Response.error(). bun test test/smoke.test.ts and tsc --noEmit pass. I did not run the whole suite; the forge's check does that on this push. I also ran the /sw.js check's extraction against the real src/web/sw.ts source, and it finds no Response.error() in the navigation branch.
--version <v> [--wait <seconds>]: the script polls/healthzuntilX-Forge-Versionequals<v>. The default limit is 120 s, and the poll interval is 1 s. If the version never arrives, it fails withwanted X-Forge-Version <v>, last saw <seen>(noneif the header was absent or the request errored) and skips the other checks. A bad--waitvalue or extra arguments exits 2 with a usage line./sw.js: it must be a 200 with a JavaScript content type. The script cuts out the navigation branch (frommode === 'navigate'to the nextreturn;), strips comments, and fails ifResponse.error(is left. The asset branch in the real worker legitimately usesResponse.error()for/assets/and/icons/, so that stays allowed.- Tests in
test/smoke.test.ts: the stub now serves/sw.jsand anX-Forge-Versionheader. New tests cover a late version, a version that never arrives (with a 100 ms limit), a bad/sw.js(an error on navigation, a non-JS type, a 404), and the CLI flags.
What I left out: the navigation-branch check is a text heuristic on the worker source, not a run of the worker. It would miss a Response.error() hidden behind a helper function. Only scripts/smoke.ts and its test changed.
To try it: bun scripts/smoke.ts https://<preview> --version <sha> --wait 60.
🤖 Generated with Claude Code
Approved. I read the diff and the real src/web/sw.ts. The navigation branch runs from mode === navigate to the first return; at line 99, and it holds no Response.error(). The asset branch after it does, and is correctly left out. The new code has no input, write or secret surface, and the tests cover the late version, the missing version, the bad sw.js cases and the CLI flags. I did not run the tests or the preview. Two things I would do next: (1) wire --version $SHA into the deploy or preview check that calls smoke.ts, since nothing in the repo uses the flag yet and the wait only matters once it does; (2) make navigationBranch stricter. The //[^\n]* comment strip also cuts string literals that contain //, such as URLs. A helper that returns Response.error() would also slip past it. A small runtime test that runs swSource with a stubbed fetch and caches and asserts the navigation response is not an error would replace the regex.
scripts/smoke.tscan now wait for a given version on/healthzand check that/sw.jsnever answers a navigation withResponse.error().bun test test/smoke.test.tsandtsc --noEmitpass. I did not run the whole suite; the forge's check does that on this push. I also ran the/sw.jscheck's extraction against the realsrc/web/sw.tssource, and it finds noResponse.error()in the navigation branch.--version <v> [--wait <seconds>]: the script polls/healthzuntilX-Forge-Versionequals<v>. The default limit is 120 s, and the poll interval is 1 s. If the version never arrives, it fails withwanted X-Forge-Version <v>, last saw <seen>(noneif the header was absent or the request errored) and skips the other checks. A bad--waitvalue or extra arguments exits 2 with a usage line./sw.js: it must be a 200 with a JavaScript content type. The script cuts out the navigation branch (frommode === 'navigate'to the nextreturn;), strips comments, and fails ifResponse.error(is left. The asset branch in the real worker legitimately usesResponse.error()for/assets/and/icons/, so that stays allowed.test/smoke.test.ts: the stub now serves/sw.jsand anX-Forge-Versionheader. New tests cover a late version, a version that never arrives (with a 100 ms limit), a bad/sw.js(an error on navigation, a non-JS type, a 404), and the CLI flags.What I left out: the navigation-branch check is a text heuristic on the worker source, not a run of the worker. It would miss a
Response.error()hidden behind a helper function. Onlyscripts/smoke.tsand its test changed.To try it:
bun scripts/smoke.ts https://<preview> --version <sha> --wait 60.🤖 Generated with Claude Code
Closes #2423