Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to register a ServiceWorker: ServiceWorker cannot be started

Everything was working fine with my Service Worker project, but suddenly I am seeing the following error:

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

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

I couldn't find anything on Google - any guidance on what causes this error to occur?

like image 391
owencm Avatar asked Mar 08 '15 01:03

owencm


1 Answers

So it turns out this just indicates there is a JS error in the Service Worker code itself, so the registration couldn't complete.

Load chrome://serviceworker-internals/ and check 'Open DevTools window and pause JavaScript execution on Service Worker startup for debugging.'

The inspector will then pop up when you refresh the page, allowing you to see the error in the Service Worker.

like image 74
owencm Avatar answered Oct 18 '22 11:10

owencm