Repository navigation
Fix the first load after upgrading to 1.0 - #50
Merged
Merged
Conversation
Reproduced with the published 0.10.0 + runtime 0.2.5 files replaced by 1.0.0 under the same URLs, in a profile that had played packages: - The demo and every embed site kept /frame-assets/ (and the embed's /libraries/) for an hour plus a day stale, under names that stay the same between versions: runtime 0.2.5's boot script ran under the new worker and every play failed. Now no-cache, a 304 when unchanged. - The element waited 3 s for the updated worker and then went ahead with the old one, which a worker of another major cannot survive: the load stayed in `indexing`. Across a major it now waits up to 30 s. - A page from before the upgrade, still open, registers loads naming main.bundle.js; the worker wrote that document without the boot route, and the 1.0 boot script at the same URL stopped with "older than this runtime". Every document names the route now; 0.2 ignores it. Closes #49. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The element keeps its routes before it asks the worker's version, so a load that began during the wait — up to thirty seconds across a major — took them as kept and went ahead with the worker of the major before, the failure of #49 by another door. `ensureWorker` now holds one setup at a time, and every load meanwhile waits on it. Also: the last worker-update test now sees the update it gave up on land; the embed's header comment no longer says a part is kept in the HTTP cache, which the element never does. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #49.
The first load after upgrading from 0.10 to 1.0 could fail. Three causes were reproduced with the published files (player 0.10.0 + runtime 0.2.5, replaced by 1.0.0 + 1.0.0 under the same URLs) and a browser profile that had played packages before. This fixes each.
Changes
1. The runtime's files and the pack are revalidated
vercel.json) and the sitesh5p-embedwrites served/frame-assets/(and the embed site/libraries/) withmax-age=3600, stale-while-revalidate=86400. The file names are the same in every version, so a returning browser kept runtime 0.2.5's boot script under the new worker. Every play failed with "Cannot read properties of undefined (reading 'H5P')" for up to an hour, plus one more load within a day. This is live on the demo now.Cache-Control: no-cacheon those paths, so the browser asks again each time and gets a 304 when nothing changed.resizer.jskeeps its hour.docs/single-worker.md#upgradingsay to serve these files revalidated, or under a versioned path.2. The element waits for a worker of another major (
h5p-offline-player.ts,constants.ts)h5p-sw.jsanswered after 4 s, the load went ahead with the 0.10 worker, the new one took over halfway through, and the load stayed inindexinguntil the test gave up at 60 s.WORKER_MAJOR_UPDATE_TIMEOUT_MS, 30 s.3. The worker names the
bootroute in every frame document (frame-document.ts)main.bundle.js. That includes a tab, and the installed app's old shell until it reloads.4. One worker setup at a time (
h5p-offline-player.ts, found reviewing the fix)ensureWorkerholds one setup promise, and every load meanwhile waits on it.Testing
New tests:
worker-update.test.ts, three tests:srcset one second into that wait is held to it, and its frame runs the new worker too (change 4; without it the frame ran the 0.99 worker at 2.3 s);/versioned/__versiontakes&delay=for this.runtime.test.ts: a load naming 0.2'smain.bundle.js, which the host no longer has, with the current boot script at its URL, plays. Without the route in the document it fails with exactly the reported message.frame-document.test.ts: the old kind of document carries the route.embed/tests/build.test.ts:no-cacheon/frame-assets/and/libraries/, invercel.jsonand the Caddyfile.The upgrade, end to end: the published 0.10.0 files, then this branch's build, under the same URLs, in a profile that had played four packages. The scripts are in the session's scratchpad.
h5p-sw.jsanswered after 4 sindexingSuites:
pnpm typecheckpasses. Player: 531 of 531 across all its projects, in Chromium. Embed: 26 of 26. Not run: Firefox and WebKit, which CI covers.Release
--force.🤖 Generated with Claude Code