Frustrating right?
Recently our team encountered this same error. Here is what was happening in our case. When the page loads, the refresh button changes to cross button, now if some api request is in progress during this page loading time and the user click this cross button, then iOS chrome/safari throws this error. For the same situation Firefox browser throws TypeError: NetworkError when attempting to fetch resource
and chrome browser throughs TypeError: Failed to fetch
.
This is not really an issue which we should be worried about, and so we decided to make sentry ignore this error by using the ignoreErrors attribute of sentry.
Sentry.init({
dsn: "sentry_dsn",
ignoreErrors: [
'TypeError: Failed to fetch',
'TypeError: NetworkError when attempting to fetch resource.',
'TypeError: cancelled'
],
});
**Note:**
Failed to fetch is also generated by CORS errors, please be mindful of that too.
Also we decided to ignore errors with statusCode in between 400 to 426 using the beforeSend callback of sentry.
We spent days trying to find this error. Hope this helps somebody.
Thank you
Also,
This was originally written here: https://forum.sentry.io/t/typeerror-failed-to-fetch-reported-over-and-overe/8447/2