Skip to content

Support for ignoring asset errors #226

@splitwarechef

Description

@splitwarechef

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions