-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Help with logging for Failed to fetch errors. #13032
-
I get a lot of failed to fetch errors. What I think happens when a request fails due to a poor network connection is Sentry will log that network error, the act of logging that network error causes another failed to fetch error. I think Sentry must store all these errors up locally so when the user eventually restores their connection my logs get bamboozled with thousands of Failed to fetch errors, instantly depleting my error capacity.
I'm adding work arounds in my code to not log errors that are a result of not being able to report an error. But here's a little snippit that will show you the URL that failed to fetch in the Sentry error logs.
var originalFetch = window.fetch window.fetch = function(resource){ return originalFetch.apply(this, arguments) .catch(function(error){ if (error.message == 'Failed to fetch'){ var newError = new TypeError(`Failed to fetch (${String(resource)})`) newError.resource = String(resource) throw newError } throw error }) }
Logs will now show 'Failed to fetch (https://a-url-that-could-not-be.reached)', giving you some visibility of what's going on.
Beta Was this translation helpful? Give feedback.