Workbox window failing to install service worker

1.3k Views Asked by At

I'm migrating form v3 to v4 , using workbox-window(CDN)and workbox-webpack-plugin in my vuejs app.

It works fine locally with http-server, but after deploying, I get this error and it fails to install the service worker.

print @ logger.mjs:44
(anonymous) @ logger.mjs:57
(anonymous) @ precache.mjs:23
Promise.catch (async)
installListener @ precache.mjs:20
PrecacheController.mjs:194 Uncaught (in promise) bad-precaching-response: The precaching request for 'https://dummyapp.com/_redirects?__WB_REVISION__=6a02faf7ea2a9584134ffe15779a0e44' failed with an HTTP status of 404.
    at PrecacheController._addURLToCache (https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-precaching.dev.js:445:15)
    at async Promise.all (index 0)
    at async PrecacheController.install (https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-precaching.dev.js:352:7)

How do I fix this?

1

There are 1 best solutions below

0
On

This happens because when a request for a precaching asset fails with a 404. In this case, the service worker installation would also fail. Check the Network tab in DevTools (ctrl+shift+i) for files that return a 404, don't precache that file. This should fix the issue.