1/** 2 * Self-unregistering service worker. 3 * 4 * History: An earlier sw.js cached large data files for offline use. After 5 * a Next.js chunk-hash rotation, those clients started returning 404 for 6 * the old chunk URLs and React 18 raised hydration error #418. The fix 7 * is to ship an SW whose only job is to immediately unregister itself, 8 * clear all caches, and force a clean reload. Once every active client 9 * has visited once after this deploy, the field is clean again. 10 * 11 * If we want real SW-backed caching later, replace this file with the 12 * actual logic. The registration call still lives in app/layout.tsx. 13 */ 14 15self.addEventListener("install", () => { 16 self.skipWaiting(); 17}); 18 19self.addEventListener("activate", (event) => { 20 event.waitUntil( 21 (async () => { 22 try { 23 const keys = await caches.keys(); 24 await Promise.all(keys.map((k) => caches.delete(k))); 25 } catch (e) { 26 // Best-effort cache wipe. 27 } 28 try { 29 await self.registration.unregister(); 30 } catch (e) { 31 // Even if unregister fails, the next page load will use the 32 // updated chunks because we didn't intercept any fetches. 33 } 34 try { 35 const clientsList = await self.clients.matchAll({ type: "window" }); 36 for (const client of clientsList) { 37 // Hard reload to drop the in-page references to the now-stale 38 // chunk URLs that triggered the original 404 / React #418. 39 client.navigate(client.url); 40 } 41 } catch (e) { 42 // Ignore â clients will pick up the new bundle on their next nav. 43 } 44 })(), 45 ); 46}); 47 48// No fetch handler â every request goes straight to the network so the 49// new build's chunk hashes resolve correctly.
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.