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
Check · Review · Land · Live done — Landed and live in production.
`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
Sign in to join this conversation.
new above
offline
findScriptsinsrc/server.tsno longer falls back to/static/<name>.js. The resolver now takes its directory, is exported, and readsstatic/once at start-up as before; every entry inGAMESmust resolve to a file that is actually there, and one that does not throws beforeBun.servebinds. The single answer to "which file instatic/is this game's bundle" moved tobundleOfinscripts/build.ts, whereisBundleOfandSTATIC_DIRalready live, andscripts/bundle.test-helper.tsnow 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:
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.mainwas in exactly that state — merging #195 and #196 left both branches'app.<hash>.jsinstatic/, and eight tests fail on it today. The first commit here isbun run scripts/build.ts, which sweeps the pair and writesapp.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.tspoint 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 againststatic/. The two assertions insrc/client/bundle.test.tsthat 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,/,/rangeand/exampleeach still point at a hashed file that exists, and the boot log lists all three.🤖 Generated with Claude Code
Closes #127