Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Help with logging for Failed to fetch errors. #13032

AlastairTaft started this conversation in Show and tell
Discussion options

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.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /