Skip to content

Ability to ignore all network/fetch/xhr errors #6376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
androidacy-user opened this issue Dec 1, 2022 · 12 comments
Closed

Ability to ignore all network/fetch/xhr errors #6376

androidacy-user opened this issue Dec 1, 2022 · 12 comments
Labels
Package: browser Issues related to the Sentry Browser SDK Type: Improvement

Comments

@androidacy-user
Copy link

Problem Statement

Our sentry issue feed is chock full of "Failed to fetch" and "A NetworkError has occurred" and more. Some of it we're able to filter out using an overcomplicated event filter on beforeSend, however, still the spam continues.

Solution Brainstorm

A native option to ignore network errors as they are almost always useless anyway.

@Lms24
Copy link
Member

Lms24 commented Dec 5, 2022

Hi @androidacy-user, thanks for writing in!

The issue of network error and other errors without stack traces has come up before (#4146, #5334). Would you mind adding your thoughts to #5334 so we can track this in one thread?

As for better ignoring these errors within the SDK, I'm afraid that it is not trivial to do so reliably. We've spent considerable time a few months ago investigating errors without stack traces and so far haven't had much success. For your specific case, have you noticed any patterns apart from error message and (lack of) stack traces that these errors share? For instance, users recently experienced an influx in errors from a few specific IP addresses (#6287).

Also, would you mind telling me, which problems you're facing in beforeSend that make it hard to filter these errors out? Furthermore, which Sentry SDK are you using? (Also, are you on self-hosted Sentry or on SaaS plan)?

@Lms24 Lms24 added Status: Needs Information Package: browser Issues related to the Sentry Browser SDK and removed Status: Untriaged labels Dec 5, 2022
@androidacy-user
Copy link
Author

Both but currently SaaS, but on self hosted we don't have to pay $200/mo for server side filtering :)

SDK is browser tracing. The beforeSend hook isn't catching everything with this:

beforeSend: function (event, hint) {
    const error = hint.originalException
    // Filter out all network, fetch, and xhr errors
    if (error instanceof Error) {
      if (error.message.match(/Network Error/i) || error.message.match(/Fetch Error/i) || error.message.match(/XHR Error/i) || error.message.match(/adsbygoogle/i) || error.message.match(/Failed to fetch/i)) {
        return null
      } else {
        // Show a feedback dialog to the user
        Sentry.showReportDialog({
          eventId: event.event_id,
          title: 'Oops! Something went wrong',
          subtitle: 'We have been notified of this issue and will fix it as soon as possible.',
          subtitle2: 'If you would like to help us fix this issue, please provide us with some additional information.',
          labelName: 'Name',
          labelEmail: 'Email',
          labelComments: 'Comments',
          labelClose: 'Close',
          labelSubmit: 'Submit',
          errorGeneric: 'An error occurred. Please try again later.'
        })
        return event
      }
    } else {
      return event
    }
  }

It filters out some but we still get a lot of NetworkError and Failed to fetch errors which are utterly useless, especially as sentry is filtering out the URLs ;p

@androidacy-user
Copy link
Author

This is especially annoying as up to 60% of our users use adblockers which cause a whole lot of fetch errors.

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@androidacy-user
Copy link
Author

Not trying to be pushy but any further response?

@Lms24
Copy link
Member

Lms24 commented Jan 3, 2023

Hi @androidacy-user, apologies for the late reply!

Your beforeSend hook looks fine to me. I know that filtering out low-quality/non-important errors is a pain. Believe me, we've tried a lot in the past...

This is especially annoying as up to 60% of our users use adblockers which cause a whole lot of fetch errors

You can do something about this by specifiying the tunnel option in the SDK.

Does this mitigate the problem for you?

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@androidacy-user
Copy link
Author

androidacy-user commented Jan 25, 2023

Hi @androidacy-user, apologies for the late reply!

Your beforeSend hook looks fine to me. I know that filtering out low-quality/non-important errors is a pain. Believe me, we've tried a lot in the past...

This is especially annoying as up to 60% of our users use adblockers which cause a whole lot of fetch errors

You can do something about this by specifiying the tunnel option in the SDK.

Does this mitigate the problem for you?

Although this mitigates one side of the problem, we still have to conduct some witchcraft with regexes and beforeSend to not quite catch everything caused by AdBlock

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2023
@androidacy-user
Copy link
Author

Anything else to add?

@mydea
Copy link
Member

mydea commented Mar 6, 2023

One other note, you may also be able to use the ignoreErrors option, which accepts an array of strings/regexes to filter out.

So you should be able to do:

Sentry.init({
  ignoreErrors: [
    /Network Error/i,
    /Fetch Error/i,
   // ...
  ]
})

This is functionally pretty much the same as beforeSend though, just a slightly nicer way to write this maybe.

@androidacy-user
Copy link
Author

One other note, you may also be able to use the ignoreErrors option, which accepts an array of strings/regexes to filter out.

So you should be able to do:

Sentry.init({
  ignoreErrors: [
    /Network Error/i,
    /Fetch Error/i,
   // ...
  ]
})

This is functionally pretty much the same as beforeSend though, just a slightly nicer way to write this maybe.

has the same shortfalls however

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: browser Issues related to the Sentry Browser SDK Type: Improvement
Projects
None yet
Development

No branches or pull requests

3 participants