0

Not a duplicate, not only this error comes "only with google chrome"; but it happened when I was messing up with my source code while at the same time my network cable physically fell off (then the error made absolute sense) but then it persisted.

I have deleted everything, from deleting all configurations, chrome cache, uninstalled workers, reinstalled chrome; the error only comes with chrome, from version 83 forwards, and only if not using incognito mode, chromium, firefox; are fine.

The error occurs even if it's the first time running the website, and only in that specific computer, the same source code, same browser, in the same exact circumstances will do fine in other computers.

Console: {"lineNumber":117,"message":"SERVICE WORKER INSTALLING","message_level":1,"sourceIdentifier":3,"sourceURL":"http://localhost:8000/sw.development.js"}
Error: {"columnNumber":-1,"lineNumber":-1,"message":"Failed to register a ServiceWorker for scope ('http://localhost:8000/') with script ('http://localhost:8000/sw.development.js'): ServiceWorker failed to install: ServiceWorker failed to handle event (event.waitUntil Promise rejected)","sourceURL":""}
Console: {"lineNumber":0,"message":"Uncaught (in promise) NetworkError: Cache.addAll() encountered a network error","message_level":3,"sourceIdentifier":1,"sourceURL":"http://localhost:8000/sw.development.js"}

I checked the network requests that the service worker was doing and they are all "304" exactly the same as chrome incognito they are all also "304", conditions are the same, all cookies cleared, all caches cleared, everything wiped; even fresh installs of chrome will do the same.

If I disable cache, as the request is done twice, hence 304 makes sense, 1st the main thread does it, then the worker, but with cache disabled I can see that the request that gives the error is indeed the only one that failed due to the cable being disconnected; with the cache enabled it shows nothing but 200 from cache, but without it, it claims to be (cancelled)

The request is to "https://fonts.googleapis.com/css?family=Open+Sans:300,400,500&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese" and it is the only one that couldn't be resolved when my cable was disconnected.

I am forced to develop now with another browser or another machine, I have never seen anything like this before; it could be something trivial.

Onza
  • 1,710
  • 4
  • 18
  • 31

1 Answers1

0

When I've seen mysterious failures along these lines in the past, it's been due to a combination of:

  1. Previous requests being made for a resource in a non-CORS mode, leading to the resource being added to the HTTP cache (not Cache Storage) as an opaque response. This might be happening if your case, for instance, if are loading that CSS file without a crossorigin="anonymous" attribute on your <link> tag.

  2. cache.addAll() will fail if any of the requests generate an opaque response.

If your HTTP cache has an opaque response, and cache.addAll() ends up using that response to attempt to populate a Cache Storage instance, then it will fail.

I am not 100% sure that that's what you're seeing, but I would see if setting crossorigin="anonymous" on any HTML that loads the CSS helps as a first step.

Jeff Posnick
  • 53,580
  • 14
  • 141
  • 167
  • Sorry for the late reply, but that didn't do anything at all; for some reason, it still only affects that one specific browser during the network situation where there was a physical issue that caused that one request to fail, it's as if like it cached the physical error and refuses to let go, I am at a loss. So far the issue has never occurred with other browsers. – Onza Sep 09 '21 at 07:52