enabled, beforeSend and ignoreErrors do not stop events from hitting Sentry with Next.js
Is there an existing issue for this?
- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [x] I have reviewed the documentation https://docs.sentry.io/
- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
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
- configure Sentry as above
- generate app router page-level error
- 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.
Hey @markedwards, thanks for writing in.
I just tried to reproduce this by setting enabled: false in sentry.server.config.ts, sentry.edge.config.ts and instrumentation-client.ts and then throwing an error.
I'm getting logs looking like this:
Sentry Logger [log]: Done flushing events
Sentry Logger [error]: Transport disabled
and I'm not seeing any errors making it to Sentry.
Could you please provide a reproduction of the issue?
I'm not sure the best way to provide a repro. I would have to set up a Sentry project and account, and build a whole Next app with the integration right? Is there a way to provide a repro that is not so much work?
Also, can you verify that you are using the same withSentryConfig() approach? I'm suspicious that some of the auto-instrumentation might be the problem here.
I tried with your config. To create a reproduction, you could use your usual Sentry org/project and leave it out before pushing it. I could then fill in my own values.
Alternatively, you could try to break my reproduction attempt here: https://github.com/andreiborza/16588-next-enabled-false
Also, could you share your config files - e.g. the content of your sentry.server.config.ts, sentry.edge.config.ts and instrumentation-client.ts and instrumentation.ts files? This is where this would be configured, the withSentryConfig method does not have anything to do with this directly.
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 🥀
I will attempt to set up some kind of repro this week. We do not have an odd implementation though, its basically exactly according to the docs.
Would mind still sharing your config files?
@markedwards Can you provide the Sentry config files? Or try to base a reproduction on the repository Andrei created (mentioned in the comment above): https://github.com/andreiborza/16588-next-enabled-false
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 🥀