fix(gui): the service worker never reuses cached imports

The worker is registered with updateViaCache set to none, so the scripts
it imports are fetched fresh on every update check.
This commit is contained in:
Juan Castro committed 2026-10-27 14:18:07 -04:00
1 parent 7aa4d91ae9
commit 7e78a4feef
2 files changed
+3 -2

No files matched your search

+2 -1
View File
@@ -157,7 +157,8 @@ export const startPushWorker = async ({
dispatchPushTap(event.data.notification);
});
try {
await nav.serviceWorker.register(WORKER_URL, { scope: '/' });
// Scripts the worker imports are fetched fresh on each update check.
await nav.serviceWorker.register(WORKER_URL, { scope: '/', updateViaCache: 'none' });
} catch ( err ) {
console.warn('Could not register the service worker:', err);
}
+1 -1
View File
@@ -217,7 +217,7 @@ describe('startPushWorker', () => {
mod.setPushTapHandler(handler);
const nav = makeNav();
await start(mod, { nav });
expect(nav.serviceWorker.register).toHaveBeenCalledWith('/sw.js', { scope: '/' });
expect(nav.serviceWorker.register).toHaveBeenCalledWith('/sw.js', { scope: '/', updateViaCache: 'none' });
const source = { postMessage: vi.fn() };
nav.listeners.message({ data: { type: 'other', notification: { uid: UID } }, source });