'How to handel "net::ERR_QUIC_PROTOCOL_ERROR 200" in a fetch?

By simulating a Lie-Fi connection I noticed that I get an (net::ERR_QUIC_PROTOCOL_ERROR) error that didn't triggered the catch part of the fetch statement. The reason that the fetch wasn't triggered is that the status code of the network request returned 200. Why is this Error OK (200)?.

But the main question is how can I detect and handle these errors?

This question gets more interesting in case the fetch is part of a fetch event handel of a serviceworker. For when the serviceworker tries to fetch something from the internet and if that isn't possible returns a result from the cache. These errors however will not be seen as an error and therefore the data from the cache will not be returned. As a user I then will not get the offline experience I would expect.

// please set Network Throttling to Lie-Fi (1kbit/s up&down)
const timeoutSimulation = () => {
  return fetch('https://thispersondoesnotexist.com/image', {mode: 'no-cors'})
    .then((response) => {
      console.log(`would not expect to see this message, due to the net error`);
      return response;
    })
    .catch((error) => {
      console.log('expect this error to be shown', error);
    })
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source