简体   繁体   中英

Service Worker Fetch Error When Trying to Load — My Website?

I've recently added Cloudfront to my web app. I'm using a WorkBox service worker and getting the error:

VM7 workbox-strategies.prod.js:1 Uncaught (in promise) TypeError: Failed to fetch

I found out from this SO post to watch the Network tab to find out what resource was causing the problem.

I checked and found out -- it's trying to load my own domain!

在此处输入图像描述

The domain loads in the browser just fine. Why would the service worker be throwing this fetch error?

What you're seeing is due to the new offline support detection in Chrome 89+.

If your site has a web app manifest and a service worker, Chrome will automatically simulate an offline connection and then make a request for the start_url listed in your web app manifest.

If your service worker uses a network-first strategy for responding to navigation requests, then there may be a failed network request logged in the Network panel, even if the check ultimately succeeds because of a response from the cache.

(The Chrome DevTools team is aware that this can be a bit confusing, and is working on improving how this is reported to developers.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM