/* * Kill-switch service worker. * * This app does not use a service worker. One was left registered on * localhost:3000 by a DIFFERENT project — service workers are scoped to an * origin, not a project, so any app later served on that port inherits it. It * intercepted requests and served dead chunks, which surfaced as * "Cannot read properties of undefined (reading 'call')" in RootLayout and * survived deleting .next and restarting the dev server. * * The browser re-fetches /sw.js to check for updates; serving this makes the * stale worker replace itself with one that immediately unregisters and drops * every cache it holds. */ self.addEventListener('install', () => self.skipWaiting()); self.addEventListener('activate', (event) => { event.waitUntil( (async () => { const keys = await caches.keys(); await Promise.all(keys.map((k) => caches.delete(k))); await self.registration.unregister(); const clientList = await self.clients.matchAll({ type: 'window' }); for (const client of clientList) client.navigate(client.url); })(), ); });