sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Error keeps being reported despite exact matching text in `ignoreErrors` list

Open adamreisnz opened this issue 8 months ago • 7 comments

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

  1. Add 'Record not found' to the ignoreErrors option array
  2. Raise an error with Record not found in the message

Expected Result

Expect for this error to be ignored by Sentry

Actual Result

Error is recorded in Sentry:

Image

Image

Image

Product Area

Processing

Link

https://arist.sentry.io/issues/6561825991/events/e38eb2019c3d4f43ac2f65b037ed17c1

DSN

https://[email protected]/4508656186163201

Version

No response

adamreisnz avatar May 14 '25 22:05 adamreisnz

Auto-routing to @getsentry/product-owners-issues for triage ⏲️

getsantry[bot] avatar May 14 '25 22:05 getsantry[bot]

Hi, @adamreisnz.

Sorry you're having trouble. The JS SDK folks would be the best ones to help you debug this, since ignoreErrors handling happens there, so I'm going to transfer this to their repo.

For whoever looks into this: The event linked above was captured with the Vue SDK, v9.9.0, with the InboundFilters integration running.

lobsterkatie avatar May 15 '25 01:05 lobsterkatie

Hey, I have tried to reproduce this but it does seem to work for me to filter this error event 🤔 Could you share your full init() code?

mydea avatar May 15 '25 08:05 mydea

Sentry.init({
    app,
    dsn,
    release: gitHash.value,
    environment: env.value,
    integrations: [
      Sentry.browserTracingIntegration({router}),
      Sentry.thirdPartyErrorFilterIntegration({
        filterKeys: ['xxxxxxxxxxx'],
        behaviour: 'drop-error-if-exclusively-contains-third-party-frames',
      }),
    ],
    trackComponents: [
      'App',
    ],
    tracesSampleRate: 1.0,
    tracePropagationTargets: [
      domains.DEV,
      domains.QA,
      domains.STAGING,
      domains.PRODUCTION,
    ],
    ignoreErrors: [

      //Specific network errors
      'Failed to fetch', //Generic fetch failures
      'Load failed', //iOS message for when fetch doesn't respond, likely a network issue
      'NetworkError when attempting to fetch resource', //CORS or network error
      'AbortError', //Occurs when a fetch request is aborted
      `Unexpected token '<'`, //Occurs when server might be down during deploy and returns a HTML page instead of JSON

      //Generic request/response errors
      'Request timed out', //Server request timeouts
      'Network error', //Generic network errors
      'Bad gateway', //Occurs when a request is made during a deploy
      'Internal server error', //Internal server errors (500)
      'Server error', //Generic server errors
      'Record not found', //Generic 404 errors

      //Auth related
      'Unauthenticated', //Unauthenticated errors
      'Unauthorized', //Unauthorized errors

      //other errors removed
    ],
  })

adamreisnz avatar May 15 '25 08:05 adamreisnz

Hmm, that seems correct. Is this still ongoing, though? Looking at the event you linked, this seemed to have happened the last time 3 days ago, was this already filtered at this time (or could it have been an outdated app version that lead to this)?

mydea avatar May 15 '25 11:05 mydea

Yes, still ongoing.

As per the screenshots, you can see we added the filter for this error type 2 months ago, yet Sentry captured an event for it 2-3 days ago.

I'll go ahead and artificially trigger another event like it now as well to verify.

On Thu, 15 May 2025, 23:04 Francesco Gringl-Novy, @.***> wrote:

mydea left a comment (getsentry/sentry-javascript#16302) https://github.com/getsentry/sentry-javascript/issues/16302#issuecomment-2883425143

Hmm, that seems correct. Is this still ongoing, though? Looking at the event you linked, this seemed to have happened the last time 3 days ago, was this already filtered at this time (or could it have been an outdated app version that lead to this)?

— Reply to this email directly, view it on GitHub https://github.com/getsentry/sentry-javascript/issues/16302#issuecomment-2883425143, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADXYQRLUVMCJA2KPK5DYVT26RYEXAVCNFSM6AAAAAB5EYRJN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOBTGQZDKMJUGM . You are receiving this because you authored the thread.Message ID: @.***>

adamreisnz avatar May 15 '25 17:05 adamreisnz

@adamreisnz Thanks for reporting this issue. Before we can determine if this is a bug in Sentry's ignoreErrors functionality, we need to understand the exact context where the error is occurring.

In Next.js, errors can be caught and reported to Sentry through different mechanisms:

  1. API Routes:

    • Direct throws (handled by Next.js error boundary)
    • Try-catch with Sentry.captureException
    • Next.js error handling middleware
  2. Client Components:

    • React Error Boundaries
    • Try-catch blocks
    • Unhandled promise rejections
  3. Server Components:

    • Next.js error handling
    • Server-side error boundaries
  4. Middleware:

    • Next.js middleware error handling
    • Custom error handling

Could you please provide:

  1. The exact location where the "Record not found" error is being thrown (API route, client component, etc.)?
  2. The code that's throwing the error?
  3. How you're capturing the error (direct throw, try-catch, etc.)?

This will help us determine if the error is bypassing Sentry's ignoreErrors check due to Next.js's error handling mechanisms, or if there's an actual issue with Sentry's error filtering.

For example, if you're throwing the error directly in an API route without try-catch:

// This bypasses Sentry's ignoreErrors
export async function GET() {
  throw new Error('Record not found');
}

Versus catching and explicitly using Sentry:

// This should respect ignoreErrors
export async function GET() {
  try {
    throw new Error('Record not found');
  } catch (error) {
    Sentry.captureException(error);
    return NextResponse.json({ error: 'Record not found' }, { status: 404 });
  }
}

The first case might be caught by Next.js's error handling before Sentry's ignoreErrors check, while the second case should properly go through Sentry's error processing pipeline.

Could you share the relevant code so we can better understand the context and determine if this is a Sentry issue or a Next.js error handling consideration?

SinaVosooghi avatar May 28 '25 11:05 SinaVosooghi

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 remove the label Waiting for: Community, I will leave it alone ... forever!


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

getsantry[bot] avatar Jun 19 '25 07:06 getsantry[bot]

Hi team,

We don't use Next.js or React, but Vue. This was an error that we deliberately captured using Sentry.captureException (or rather, to be more precies, the code base has been set up that it automatically feeds into Sentry.captureException when we encounter an API error).

The relevant code:

//Process an error
  const processError = error => {

    //Ensure error in error processing doesn't trigger an error itself
    try {

      //No error? 🤨
      if (!error) {
        //Seems to originate from Sentry itself, according to this comment:
        // NOTE: If you are a Sentry user, and you are seeing this stack frame, it
        //       means the sentry.javascript SDK caught an error invoking your application code. This
        //       is expected behavior and NOT indicative of a bug with sentry.javascript
        Sentry.captureException(new Error('Error is empty'), {level: 'info'})
        return
      }

      //Ensure error is an object
      if (typeof error !== 'object') {
        Sentry.captureException(new Error(`Error is not an object: ${error}`), {level: 'info'})
        return
      }

      //Already processed?
      if (error.isProcessed) {
        return
      }

      //Log to console
      console.error(error)

      //Capture in Sentry
      if (!error.ignoreInSentry) {
        Sentry.captureException(error)
      }

      //Flag as processed
      error.isProcessed = true
    }
    catch {
      //Fall through
    }
  }

adamreisnz avatar Jun 22 '25 21:06 adamreisnz

Did you try to trigger this error again? When doing this locally with debug: true, do you see any logs about sent/filtered errors?

s1gr1d avatar Jun 24 '25 08:06 s1gr1d

I was able to reproduce this error in a Nuxt app (which is using Vue under the hood as well) when SSR was enabled. As the page was created on the server, the error message needed to be added to ignoreErrors in the server config as well to be filtered.

Do you have any sever rendering enabled in your Vue application? Can you share your application setup?

The interesting thing is, that beforeSend is not called for the error that should be filtered, but it gets sent to Sentry nevertheless. I haven't found the cause for this yet.

s1gr1d avatar Jun 24 '25 12:06 s1gr1d

Hi, sorry for the late reply. We don't have the debug flag enabled, but if I have time I will try to reproduce locally (Sentry is generally disabled locally altogether).

SSR is not enabled in the Vue application.

adamreisnz avatar Jul 07 '25 02:07 adamreisnz

Thank you, yeah it would be interesting what the debug logs say.

s1gr1d avatar Jul 07 '25 08:07 s1gr1d

I haven't seen this one pop up lately, so I want to tentatively say this has either been fixed, or Sentry stopped linking (different) new issues to that same "Not found error" issue. Either way, I'll close this out for now and will keep an eye on it happening again, thank you!

adamreisnz avatar Jul 16 '25 21:07 adamreisnz