Failed to register a ServiceWorker: ServiceWorker cannot be started

青春壹個敷衍的年華 提交于 2020-08-22 09:58:47

问题


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:


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.



来源:https://stackoverflow.com/questions/28921937/failed-to-register-a-serviceworker-serviceworker-cannot-be-started

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!