Skip to content

enabled, beforeSend and ignoreErrors do not stop events from hitting Sentry with Next.js #16588

Open
@markedwards

Description

@markedwards

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

9.29.0

Framework Version

Next 14.2.30

Link to Sentry event

https://bluefish-labs-inc.sentry.io/issues/6582022256/?project=4509037642842112&query=is%3Aunresolved&referrer=issue-stream&stream_index=0

Reproduction Example/SDK Setup

We have Sentry integrated into Next.js according to this documentation: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

We want Sentry to be included in CI builds, so that it is tested, but we want to filter out events emitted in CI to eliminate noise. Attempting to do this using beforeSend: () => null, or ignoreErrors: [/.*/], or even enabled: false does not stop events from appearing in Sentry.

The test case I'm using is a simple test error implemented by throwing in a Next.js app router page. If I enable debug logging, I can see that the beforeSend is triggered and the logging claims the event is being dropped, but it shows up in Sentry nonetheless.

The relevant Next configuration is:

module.exports = withSentryConfig(nextConfig, {
  authToken: process.env.SENTRY_PLATFORM_AUTH_TOKEN,
  autoInstrumentAppDirectory: true,
  autoInstrumentMiddleware: true,
  autoInstrumentServerFunctions: true,
  disableLogger: true,
  org: "our-org-name",
  project: process.env.SENTRY_PLATFORM_PROJECT,
  tunnelRoute: "/monitoring",
  widenClientFileUpload: true,
});

Steps to Reproduce

  1. configure Sentry as above
  2. generate app router page-level error
  3. observe that the error shows up in Sentry even though Sentry is disabled, or all events are filtered

Expected Result

Events should not show up in Sentry if the integration is disabled or if events are filtered.

Actual Result

Events appear in Sentry.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions