bugsnag/bugsnag-js

[Feature request / question] A way to ignore errors based on the breadcrumbs?

ian-whitestone opened this issue · 2 comments

Description

We are using New Relic for observability in our React/NextJS application. It is currently causing this error to fire on many different pages throughout our application:

Unhandled Promise Rejection: Failed to fetch

CleanShot 2023-07-06 at 22 20 39@2x

As per the breadcrumbs, we can see this is always happening when New Relic is making a post request and it fails.

CleanShot 2023-07-06 at 22 15 46@2x

Describe the solution you'd like

A way in the UI, or in the bugsnag configuration, to ignore all errors that originate from this type of New Relic request.

Describe alternatives you've considered

  • From what I can tell, there isn't a way to explicitly "catch" and ignore errors from new relic, since it is an agent that runs in the background.
  • I saw this solution which lets us ignore errors based on the message text, but I don't want to ignore all Unhandled Promise Rejection: Failed to fetch errors, only ones that were caused by the New Relic fetch failing.
    • Perhaps there is a way to access the breadcrumbs when using the pattern the author suggests in this post?

Any thoughts or advice would be greatly appreciated!

Hi @ian-whitestone,

It is possible to access the breadcrumb information from within an onError callback
Something like below would check if the most recent breadcrumb's request url is that of New Relic and then prohibit sending that event.

  onError: function (event) {
    if(event.breadcrumbs[event.breadcrumbs.length-1].metadata["request"].includes("bam.nr-data.com")){
      return false
    }
}

Obviously this is a relatively simplistic example and you could extend that to be more specific for your own needs.
Would something like this suit your needs?

As we haven't heard back from you in a while, going to close this out. I hope the above solution fits your needs but do let us know if not and we can reopen this as necessary.