Skip to content

a deploy must not break tabs that are already open - #21

Merged
swimmingbrain merged 1 commit into
mainfrom
fix/stale-chunks
Aug 26, 2026
Merged

swimmingbrain merged 1 commit into
mainfrom
fix/stale-chunks

Conversation

@swimmingbrain

Copy link
Copy Markdown
Owner

Someone on Firefox got this after one of today's deploys:

Fehler beim Laden von 'https://tex.swimmingbrain.dev/_app/immutable/chunks/Dj71MaAg.js'.
Ein ServiceWorker fing die Anfrage ab und es kam zu einem unerwarteten Fehler.

A tab that was open before the deploy still had the old chunk names, GitHub Pages had already replaced the files, and the service worker had nothing to fall back to. Any navigation inside the app after a deploy could hit it.

What changed

  • The service worker is a SvelteKit one now (src/service-worker.ts instead of static/sw.js). It knows the file list of the build it belongs to, caches all of it on install in a cache named after the build, and serves the app's chunks from there. A page and its chunks always come from the same build, whatever the server has by now. Old build caches are dropped on activate, the tex live cache and the mirror setting stay.
  • The tex live part is the same code as before, moved over.
  • Nothing inside the worker can fail an interception anymore: every cache call is guarded (private windows in Firefox have no cache storage at all) and every handler falls back to a plain fetch.
  • The app polls for new versions once a minute and does a full page load on the next navigation after a deploy, so a tab never asks for chunks that don't exist anymore.
  • The tex live subset and the engine are kept out of the worker's file list, otherwise the worker itself is 200 KB of file names. It is 7 KB now.

Tested on the built site: 40 files precached, the editor loads and compiles with every chunk deleted from the server, fresh tabs compile through the worker as before.

… can't pull the chunks out from under an open tab
@swimmingbrain
swimmingbrain merged commit a87f874 into main Aug 26, 2026
2 checks passed
@swimmingbrain
swimmingbrain deleted the fix/stale-chunks branch August 26, 2026 15:57
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.

1 participant