Repository navigation
fix: keep PWA app shell and its files consistent after a rebuild - #26464
Closed
totally-not-ai[bot] wants to merge 2 commits into
Closed
totally-not-ai[bot] wants to merge 2 commits into
totally-not-ai[bot] wants to merge 2 commits into
Conversation
In development mode, the service worker sent every /VAADIN/ request network-first, so a precached app shell from the previous build loaded its entry script from the server, which no longer had it, and the page stayed blank. Precached dev bundle files are now served from the precache. The worker of a new build also no longer activates while pages of the previous build are open, as activating removed the previous build's files from the precache that those pages still load from. Fixes #24800
Without skipWaiting() in the generated worker, a worker rebuilt after an edit to sw.ts waited until all pages were closed. The dev server update now asks the rebuilt worker to activate.
Contributor
Author
|
Superseded by #24807, which now contains these changes. |
|
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.



Review risk: two-way door — only the generated PWA service worker (
sw.ts) and the dev server's service worker update change; affects apps using@PWAwith offline support, reverting is a one-file change.Fixes #24800
Summary
After a frontend rebuild, an installed PWA could show a permanent blank page on the next reload. This happened when the service worker answered the reload with its precached app shell from the previous build. In development mode, the worker fetched every
/VAADIN/file network-first, so the old shell's entry script was requested from the server, which no longer had it. The worker then passed the server's 404 through and never checked the precache.Supersedes #24807, which removed only
skipWaiting(). With just that change, the blank page still appeared, and a reload no longer recovered it because the new worker stayed in "waiting".What changed
/VAADIN/files that are in the precache are now served from the precache instead of network-first. The files have a content hash in their name, so this is the same cache-first handling production builds already use. Non-precached/VAADIN/URLs (e.g. the Vite dev server's modules) are still network-first.self.skipWaiting(). A worker from a new build now waits until the previous build's pages are closed. Activating right away removed the previous build's files from the precache while those pages could still load from it (e.g. lazy route chunks in another open window).clientsClaim()is kept so the first install still controls the page without a reload.sw.tsstill takes effect in the open page. After the update check, the dev server asks the rebuilt worker to skip waiting through a newVaadin.ServiceWorker.skipWaitingmessage.index.htmland files on reload.Test summary
@PWAapp in dev-bundle mode, driven by headless WebKit (Playwright) and Chromium: install the worker, rebuild with a frontend change and restart the server, then click in the still-open page.maingives a 404 on the oldindexhtml-*.jsand a blank page. With this change, the app loads.sw.ts, in Chromium: the rebuilt worker activates and takes over the open page. Without the message it stays in "waiting".🤖 Generated with Claude Code