Skip to main content

[Next.js] Why do I see a non-debug bundle warning when enabling debug mode?

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.

  1. Open the Next.js config where you call withSentryConfig.

  2. Set webpack.treeshake.removeDebugLogging to false, or remove that option so the default (false) applies.

  3. Rebuild the app, keep debug: true in Sentry.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.

Did this answer your question?