An unknown error occurred when fetching the script (Service Worker)

人走茶凉 提交于 2019-12-03 23:57:18

I had exactly the same problem, I spent an hour trying to figure it out and it turned out that I had another tab for the same origin left opened somewhere (so using the same shared Service Worker) that had the "Offline" checkbox left checked and that prevented another tabs from requesting sw.js for some reason.

It seems that the offline state is leaking from the tab within Service Worker scope while not being properly reflected nor managed by the other tabs than the one that was turned Offline first.

So make sure you have no other clients running the same Service Worker - you should be able to find them listed in DevTools > Application > Service Workers.

For me this error went away when i added sw.js to the cache upon install. Simply forgot to do that, but it solved the issue.

I had this issue while working in an Angular project. My problem was that I was using Angular CLI's built-in ng serve -prod command.

To make it work, I used ng build -prod and then host the resulting dist folder using http-server

In Chrome, what I did was to check the option Bypass for network and then I was able to reload.

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