40

After upgrading to Chrome 64, I realized that this error appears when I load my page on a new tab.

enter image description here

I can't identify where it is on the service worker. Here is my code to run the fetch:

self.addEventListener('fetch', function(event) {
   if (event.request.url.startsWith(self.location.origin)) {
       event.respondWith(
           caches.match(event.request).then(function(response) {
              return response || fetch(event.request).then(function(fetch_resp){
                  return fetch_resp;
              });
           })
       );
   }
});

Could anyone here, who has more knowledge about service worker, help me to solve this error?

Mark Fisher
  • 711
  • 8
  • 26
N. Dias
  • 544
  • 1
  • 6
  • 11
  • I'm looking into this a bit. In the meantime, any idea as to whether you see this error only when DevTools is open? I know that it's hard to figure that out, since you can't necessarily check for the error without opening DevTools... the reason I ask is that https://github.com/paulirish/caltrainschedule.io/pull/51/files sounds similar. – Jeff Posnick Jan 26 '18 at 20:51
  • Here is [some documention](https://developer.mozilla.org/en-US/docs/Web/API/Request/cache), so it seems to be related to the *Request.cache* API. – BairDev Mar 23 '18 at 15:10

3 Answers3

42

I believe this is a Chromium bug that has been reported here. Hopefully it will be fixed soon or some more information about the issue will be published.

Paul Irish implemented a temporary work around, which is as follows:

if (e.request.cache === 'only-if-cached' && e.request.mode !== 'same-origin') {
  return;
}

I ran it inside the callback for the service worker install and fetch listeners and it prevented the error.

You can see the full commit of Paul's code here.

rjbultitude
  • 877
  • 12
  • 13
  • Getting it on Outlook.com on Google Chrome, is this the same as Chromium? – lllllllllllllIllllIll Oct 17 '18 at 19:50
  • 1
    @lllllllllllllIllllIll Chromium is the open-source project that the Chrome browser is based on. Chrome as a browser includes additional features and technologies that require licensing - Chromium does not include these things among other smaller differences. https://en.wikipedia.org/wiki/Chromium_(web_browser) – seangwright Nov 21 '18 at 20:59
0

For those searching for this again, seems like it popped up after a while again when someone opens the devtools you can still see the error mentioned in the question.

See (new) bug report here: https://bugs.chromium.org/p/chromium/issues/detail?id=1098389

So let's hope this will be fixed again soon!

rsz
  • 1,047
  • 1
  • 15
  • 33
-1

perhaps the cache name is not unique from other applications, seems to fix the issue for me.