I run a standard Nginx reverse proxy with instructions from one of the official tutorials with DigitalOcean.
In the past few weeks, I started to notice (and others, too) random “Cannot Load App” messages when visiting the forum. Just randomly and semi-rarely. Refreshing with F5 instantly shows the site again.
I think the message that we send when fetch throws an error is confusing.
// The catch is only triggered if fetch() throws an exception, which will most likely
// happen due to the server being unreachable.
// If fetch() returns a valid HTTP response with an response code in the 4xx or 5xx
// range, the catch() will NOT be called. If you need custom handling for 4xx or 5xx
// errors, see https://github.com/GoogleChrome/samples/tree/gh-pages/service-worker/fallback-response
If the server is unreachable, it doesn’t mean that the client is offline and I think this is why a lot of people are getting confused.
I had this great idea that we should only display the offline page by figuring out what type of error we’re getting. However…
A fetch() promise will reject with a TypeError when a network error is encountered or CORS is misconfigured on the server side, although this usually means permission issues or similar
So I experimented locally and get the same error, TypeError: Failed to fetch, whether I am offline or whether the server is down. No way of telling why the fetch request fails. The console does log net::ERR_CONNECTION_REFUSED but that is not available to us…
Even a Google Engineer wrote this in his blog post…
This is hands down, one of the worst error messages I’ve ever seen.