fix(web): default the socket to TLS, and cache-bust the deployed bundles

?ws= now takes a host:port and the page supplies the scheme: wss:// when it
is itself served over https, ws:// when over http. An explicit ws:// from an
https page is UPGRADED rather than passed through, because an https origin
refuses it as mixed content -- so passing it through can only produce a
failure that reads like 'the server is not running'. The scheme is not the
caller's to get wrong.

And the deploy now stamps ?v=<sha> onto both bundles. Pages serves everything
max-age=600 and the wasm-pack filenames carry no content hash, so for ten
minutes after a deploy a returning visitor runs the PREVIOUS build -- which
made a shipped fix look like it had not shipped, twice, during the first real
browser debugging session.

BOTH halves are stamped, because a fresh glue file does not pull a fresh
.wasm: the glue locates it with new URL('..._bg.wasm', import.meta.url), and
a URL built against a base does not inherit the base's query. Stamping only
the import specifier would refresh the wrapper and keep the stale binary --
exactly the failure this is here to end.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EoW5BB87ZZdm96SvBTWawH
This commit is contained in:
Edward Langley
2026-09-19 21:17:08 -07:00
parent 6e1ba77d70
commit 94d26d8705
4 changed files with 76 additions and 18 deletions
+23
View File
@@ -139,6 +139,29 @@ jobs:
cp -rf web/worker-pkg site/worker-pkg
rm -f site/pkg/.gitignore site/pkg/package.json
rm -f site/worker-pkg/.gitignore site/worker-pkg/package.json
# Cache-bust the two generated bundles. Pages serves everything
# `max-age=600` and the wasm-pack filenames carry no content hash,
# so for ten minutes after a deploy a returning visitor runs the
# PREVIOUS build -- which during improvise-9x6 debugging made a
# shipped fix look like it had not shipped, twice. The specifiers
# are static import strings, so stamping the copies in site/ is
# enough; the tracked sources are left alone and a local
# `http.server` is unaffected.
# Both halves, because a fresh glue file does NOT pull a fresh
# .wasm: the glue locates it with
# `new URL('..._bg.wasm', import.meta.url)`, and a URL constructed
# against a base does not inherit the base's query string. Stamping
# only the import specifier would refresh the wrapper and keep the
# stale binary -- the failure mode this is here to end.
sed -i "s|\./pkg/improvise_wasm_client\.js|&?v=${GITHUB_SHA}|" site/app.js
sed -i "s|\./worker-pkg/improvise_worker_server\.js|&?v=${GITHUB_SHA}|" site/worker.js
sed -i "s|'improvise_wasm_client_bg\.wasm'|'improvise_wasm_client_bg.wasm?v=${GITHUB_SHA}'|" \
site/pkg/improvise_wasm_client.js
sed -i "s|'improvise_worker_server_bg\.wasm'|'improvise_worker_server_bg.wasm?v=${GITHUB_SHA}'|" \
site/worker-pkg/improvise_worker_server.js
grep -n "?v=" site/app.js site/worker.js \
site/pkg/improvise_wasm_client.js \
site/worker-pkg/improvise_worker_server.js
find site -type f | sort
du -sh site