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

forked from trevato/cs · proposes

A missing bundle is a loud failure, not a dead canvas: the server refuses to start without the script each game ships #198

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`findScripts` in `src/server.ts` no longer falls back to `/static/<name>.js`. The resolver now takes its directory, is exported, and reads `static/` once at start-up as before; every entry in `GAMES` must resolve to a file that is actually there, and one that does not throws before `Bun.serve` binds. The single answer to "which file in `static/` is this game's bundle" moved to `bundleOf` in `scrip…

shipped production is serving it deploy ae07c2d

opened this

findScripts in src/server.ts no longer falls back to /static/<name>.js. The resolver now takes its directory, is exported, and reads static/ once at start-up as before; every entry in GAMES must resolve to a file that is actually there, and one that does not throws before Bun.serve binds. The single answer to "which file in static/ is this game's bundle" moved to bundleOf in scripts/build.ts, where isBundleOf and STATIC_DIR already live, and scripts/bundle.test-helper.ts now asks the same function the server boots on rather than keeping its own copy of the rule.

A failed deploy reads like this, on the line after the source frame:

error: the game "app" has no bundle: nothing in /app/static is named app.<hash>.js — run `bun run scripts/build.ts` and commit what it writes

Two bundles for one game is the same failure (the game "app" has 2 bundles in …: app.6bbbaf11e0.js, app.46e58255bb.js — all but one are stale, so run …), because nothing can say which one a visitor should run. That is a deliberate behaviour change beyond the issue: a preview that deploys without its committed bundle, or with a stale one beside it, is now a failed deploy instead of a dead canvas.

main was in exactly that state — merging #195 and #196 left both branches' app.<hash>.js in static/, and eight tests fail on it today. The first commit here is bun run scripts/build.ts, which sweeps the pair and writes app.4933b16c8f.js, the bundle today's merged sources produce. That is also why the README's ceiling table is updated: it was measuring bundles from several pulls ago.

New tests in src/server.test.ts point the resolver at an empty directory (and a missing one) and assert it throws naming the game and the build command, at a directory holding a correctly hashed bundle for every game and assert each resolves to that exact file, and at a doubled bundle; a fourth reads the running server's map back against static/. The two assertions in src/client/bundle.test.ts that pinned the old helper's wording were updated because the message moved, not because the behaviour was wrong. bun test: 867 pass, 0 fail. In the preview, /, /range and /example each still point at a hashed file that exists, and the boot log lists all three.

🤖 Generated with Claude Code

Closes #127

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs