Issue
I set debug: true in my @sentry/nextjs SDK initialization and see this console warning: [Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle. SDK debug logging does not appear in the console.
Applies To
All SaaS Customers and Self-Hosted Users
Next.js SDK
SDK Setup
Resolution
This warning appears when you enable debug: true after the SDK debug logging code was tree-shaken out of your webpack build. Keep the debug logger in the bundle, then rebuild.
Open the Next.js config where you call
withSentryConfig.Set
webpack.treeshake.removeDebugLoggingtofalse, or remove that option so the default (false) applies.Rebuild the app, keep
debug: trueinSentry.init, and confirm SDK debug logs appear in the console.
Example:
withSentryConfig(nextConfig, {
webpack: {
treeshake: {
removeDebugLogging: false,
},
},
});
Tree-shaking options apply to webpack builds only. They are not supported for Turbopack builds.
If you remove debug logging to shrink production bundles, enable debug: true only in environments where removeDebugLogging is false.
For full option details, see the Next.js tree shaking documentation.
