Skip to content

Clear the game's service worker from the manual's host - #2347

Merged
maniator merged 2 commits into
mainfrom
help-host-sw
Nov 15, 2026
Merged

maniator merged 2 commits into
mainfrom
help-host-sw

Conversation

@maniator

Copy link
Copy Markdown
Owner

Requested by Naftali · project thread

What & why

Urgent fix for 4.5.0, to ship as 4.5.1 right after merge.

help.verticopolis.com served the game for a few minutes after its domain moved to Production and before 4.5.0 (#2339) deployed. A browser that opened it in that window installed the game's service worker on the help host. That worker answers every manual page with the game's title screen (and the game then tidies the address, dropping the slash and ?from=game), until a hard reload. verticopolis.com/help links 308 to the same host, so they show the game too. The server itself is right: curl https://help.verticopolis.com/rooms returns the manual.

The help host never served a sw.js (it was a 404), so the browser kept the stale worker. Every build now writes dist/help/sw.js, served as help.verticopolis.com/sw.js, with the same self-removing worker previews already use (src/build/previewDeploy.ts). The browser's next update check, after any navigation or the stale game page's own check, installs it, and it deletes Workbox's caches, unregisters and reloads the page from the network, which now gets the manual. The manual never registers a worker, so nothing reinstalls one.

  • HELP_HOST_SERVICE_WORKER shares its lifecycle code with RETIRING_SERVICE_WORKER and has its own first line, so the production check that refuses the preview marker in dist/sw.js is unaffected.
  • applyHelpHostWorker writes it from scripts/preview-service-worker.ts, which scripts/vercel-build.sh already runs after the help build, and fails if the help site wasn't built.
  • vercel.json already serves /sw.js with max-age=0, must-revalidate, and the help host's rewrite maps it to /help/sw.js.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • Classic-canon fix (matches the 1994 original for all towers)
  • Modern-mode feature (opt-in, "what the original couldn't do")
  • New player-facing feature (mode-agnostic)
  • Refactor / internal-only (no player-facing behavior change)
  • Docs / tooling

Game mode impact

n/a: the manual's host only. The game's own worker and its origin are unchanged.

Quality gates

  • npm run typecheck
  • npm run lint
  • npm test (CI. src/build/previewDeploy.test.ts passes locally, 22 tests, now running every lifecycle test against both workers.)
  • npm run build (CI. node scripts/preview-service-worker.ts ran locally and wrote dist/help/sw.js.)

Versioning

  • Added a .changes note with the right app: and crate: levels, or this PR changes no deployed path
  • Engine change: updated packages/verticopolis-engine/README.md and/or engine-rs/CRATE_README.md, or read both and put readmes: unchanged in the note, or this PR changes no engine source

Complexity

n/a: no hot path. One build step writes one small file; the worker runs once per affected browser and removes itself.

Hot-path record (section 6): no hot-path surface

Screenshots / recordings

n/a: Naftali's report in the project thread shows the game's title screen at help.verticopolis.com/rooms. After deploy, help.verticopolis.com/sw.js should return the worker starting // Verticopolis manual host.

Notes for reviewers

  • Workaround until it ships: DevTools, Application, Service workers, Unregister on help.verticopolis.com.
  • Most players never opened the help host in that window, so few browsers are affected, but anyone who did stays stuck until this ships.

Generated by Claude Code

help.verticopolis.com served the game for a few minutes when its domain
moved to Production before 4.5.0 deployed. A browser that opened it then
installed the game's service worker on that host, and the worker kept
answering every manual page, and every /help redirect that lands there,
with the game's title screen until a hard reload.

Every build now writes dist/help/sw.js, served as help.verticopolis.com/sw.js,
with the same self-removing worker previews use: the browser's next update
check installs it, it deletes Workbox's caches, unregisters, and reloads the
page from the network, which now gets the manual. It carries its own first
line, so the production worker check, which refuses the preview marker in
dist/sw.js, is unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7trYsinXUbmcSQZ3d6N7
@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
verticopolis Canceled Canceled Nov 15, 2026 11:39pm UTC

Request Review

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T23:33:29.713248Z
We couldn’t complete this review. Comment @codex review to try again.
fae7ec1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions Bot added this to the 4.x milestone Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Focused review of fae7ec180 (bmad-code-review layers + stand-in review, hotfix scope)

The bug is live. Production (4.5.0, cb85b56) answers https://help.verticopolis.com/sw.js with a 404. A failed update check leaves the existing registration in place, so a browser that got the game's worker on that host keeps serving the game's precached index.html for every manual page. The only fix is to serve a script there that replaces that worker.

What I checked:

  • The help host serves it. vercel.json sends the help host's /sw.js through the ^/sw\.js$ header route first (max-age=0, must-revalidate, on the request path), then the help host rewrite turns it into /help/sw.js, which this PR writes to dist/help/sw.js. The update check therefore gets a 200 JavaScript response that differs from the cached script, and the browser installs it. The script request itself bypasses the stale worker.
  • Unregister and reload. The body is the preview worker's, now shared through retiringWorkerBody(). RETIRING_SERVICE_WORKER comes out byte for byte the same as before. On install it calls skipWaiting. On activate, the pages the old worker controlled move to this worker (same registration), and it deletes the Workbox caches, unregisters, then navigates each window. Because it unregisters first, the reload goes to the network and gets the manual. The tests cover a refused navigate and a Cache Storage failure, and the 22 tests in previewDeploy.test.ts pass locally. One limit: the first visit still shows the game, and the update check that follows it fixes the page. The change note describes that correctly.
  • No loop. The manual registers no worker, so after the reload nothing is in scope to update again. The worker could only loop if the help host served the game's page, and on any deployment carrying this PR it serves dist/help/. An older deployment (a rollback) has neither the help host routes nor this file, so the loop cannot start there either.
  • Game origin unaffected. dist/sw.js and applyPreviewWorker are unchanged. The help worker is written after the Workbox build (precache already sealed, help/** ignored), so the game never precaches it. Its first line does not carry the preview marker, so check-production-worker.ts (which reads dist/sw.js only) and the production gate are untouched. On verticopolis.com, /help/sw.js is redirected by the 308, and nothing registers it at the /help/ scope on previews.
  • Deploy check: dist/help/sw.js is in web-SHA256SUMS and is fetched at help.verticopolis.com/sw.js by the post-deploy byte check from Give the help site the game's menu bar, and move it to help.verticopolis.com #2339, which matches what the help host serves.
  • Change note: app: patch, crate: none, correct for a fix. History is one commit, rebased on current main.
  • Hot path: the only listed surface touched is src/build/previewDeploy.ts, and the change is the worker text plus a build-script helper. vite.config.ts still imports only isPreviewDeploy, which is unchanged. No runtime or engine path changes.

No findings.

GO at fae7ec180e822f1e0f5b91fd83ca8ec7295cbb2a, once required CI is green (the Vercel deploy and the checks were still pending when I looked). After 4.5.1 deploys: curl -I https://help.verticopolis.com/sw.js should return 200 with cache-control: public, max-age=0, must-revalidate.

Reviewed against Verticopolis conventions (.github/copilot-instructions.md).


Generated by Claude Code

check-production-worker now also reads dist/help/sw.js and stops the
deploy unless it is exactly the manual host's self-removing worker, so
help.verticopolis.com can never go live without the file that clears a
game worker a browser left there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7trYsinXUbmcSQZ3d6N7

Copy link
Copy Markdown
Owner Author

Re-review of 3716af993 (delta since fae7ec180)

The only new commit, "Fail the production deploy without the manual host's worker", adds a production gate and changes nothing that runs in a browser:

  • helpHostWorkerProblem fails a missing dist/help/sw.js and anything that is not byte-for-byte HELP_HOST_SERVICE_WORKER. applyHelpHostWorker writes exactly that string, so a normal production build passes.
  • check-production-worker.ts finds the help worker next to the sw.js path it is given (dist/help/sw.js) and checks both. Its only caller is the step in deploy-production.yml that runs after vercel build --prod, and vercel-build.sh has written the file by then. No other build or CI job runs this check, so a local build without the help site cannot trip it.
  • The worker text is unchanged: HELP_HOST_WORKER_MARKER builds the same first line as before. The new tests reject a missing file, an empty one, the precaching worker and the preview worker. All 24 tests in previewDeploy.test.ts pass locally.

No findings. The GO carries to 3716af993ed, with the same condition: required CI green before merge.

Reviewed against Verticopolis conventions (.github/copilot-instructions.md).


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

📸 Screenshot drift check

No drift: the committed screenshots already match a fresh deterministic generation. ✅

@maniator
maniator merged commit 2d4ed03 into main Nov 15, 2026
44 checks passed
@maniator
maniator deleted the help-host-sw branch November 15, 2026 23:44

This branch was successfully deployed

1 active deployment
Preview — 3716af99 Deployed Nov 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants