We keep getting 404 / 500 errors after a new build, and it's always because sw.js tries to load a file that doesn't exist anywhere on our servers.
I can understand this, as at times, the service worker is outdated, but in some cases, even after a new build, we still get the 500 errors and going to check the entry for the specific file, it's added to the service worker even when it doesn't whereas, every other thing is updated.
If the errors for this module (esp after build) can be ignored, it would be very much appreciated.
I don't know how to reproduce this, but it happens too often to be ignored.
This is my sw.ts file
import { cleanupOutdatedCaches, precacheAndRoute } from "workbox-precaching";
import { clientsClaim } from "workbox-core";
import { FitSWEvents } from "./types";
declare const self: ServiceWorkerGlobalScope;
self.skipWaiting();
clientsClaim();
const entries = self.__WB_MANIFEST;
function pubMessageToClients(type: string | FitSWEvents, data: any) {
self.clients.matchAll().then((clients) => {
clients.forEach((client) => {
client.postMessage({ type, data });
});
});
}
if (import.meta.dev)
entries.push({ url: "/", revision: Math.random().toString() });
globalThis.setInterval(() => {
pubMessageToClients(FitSWEvents.TIMER_ONE_MINUTE, null);
}, 1000 * 60);
cleanupOutdatedCaches();
precacheAndRoute(entries);
We keep getting 404 / 500 errors after a new build, and it's always because sw.js tries to load a file that doesn't exist anywhere on our servers.
I can understand this, as at times, the service worker is outdated, but in some cases, even after a new build, we still get the 500 errors and going to check the entry for the specific file, it's added to the service worker even when it doesn't whereas, every other thing is updated.
If the errors for this module (esp after build) can be ignored, it would be very much appreciated.
I don't know how to reproduce this, but it happens too often to be ignored.
This is my
sw.tsfile