12

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?

1 Answer 1

36

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.

7
  • Out of curiosity, which Chrome version/channel were you using? Commented Mar 9, 2015 at 0:50
  • I was using Canary 43 (it's updated since so afraid I can't give the exact version)
    – owencm
    Commented Mar 9, 2015 at 3:13
  • Thanks. Our work on bringing SW and Page debugging within the same devtools window should help make that more obvious. Commented Mar 10, 2015 at 4:01
  • i was getting a error like window is not defined in firebase-app.js file but when i gone to chrome://serviceworker-internals/ clicking on unregister and then register solved my problem. So why did i was getting that error ?Any help would be appreciated Commented Jan 8, 2018 at 10:43
  • 2
    Is there an equivalent solution for Firefox?
    – kemp
    Commented Jan 23, 2019 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.