Failed to register ServiceWorker: ServiceWorker could not be started

Everything worked perfectly with my Service Worker project, but suddenly I see the following error:

Uncaught (in promise) DOMException: Failed to register a ServiceWorker: ServiceWorker cannot be started 

This is reported as index.html: 1, although I am registering SW in a file called sw.js.

I could not find anything on Google - any indication as to the cause of this error?

+6
source share
1 answer

So, it turns out that this simply indicates a JS error in the Service Worker code, so the registration cannot complete.

Download chrome: // serviceworker-internals / and check the box "Open DevTools" and pause JavaScript when starting Service Worker for debugging.

Then the inspector will appear when you refresh the page, which will allow you to see the error in Service Worker.

+15
source

Source: https://habr.com/ru/post/983484/


All Articles