How could I disable auto release for @sentry/nextjs

I’m using @sentry/nextjs but it just releases even I haven’t set any of the options.
Also I couldn’t find how to disable auto release. Is there a solution?

1 Like

Can you define what you mean by “just releases”?
Do you mean uploading source maps?

I’m also using @sentry/nextjs (6.4.1) and it really “just releases, a.k.a uploads release files to Sentry”.

Steps to reproduce:

  1. Create a Next.js app npx create-next-app nextjs-sentry
  2. Install Sentry yarn add @sentry/nextjs
  3. Configure Sentry npx @sentry/wizard -i nextjs

The wizard will then automatically add configuration files to next.js project:

  • sentry.client.config.js
  • sentry.server.config.js
  • next.config.js
  • sentry.properties

After that the Sentry is “automatically” in use/enabled to your next.js app.

This means that when you:

Run the development server (http://localhost:3000/)
next dev

The app will “automatically” send an error logs to the Sentry (source maps upload is disabled).

Also keep in mind, by default we disable source map upload in dev mode when running next dev to not upload the source maps on every file change. If you build your app for production, we’ll upload your source maps by default.

There is an option to remove/control dsn value Sentry.init({ dsn: null }) to avoid sending error messages to the Sentry but this is not a correct way to “disable Sentry in development server”.

Sentry is still “enabled” in development server but the app just doesn’t send an error logs to the Sentry if dsn value is null or incorrect.

Build and deploy Next.js app (http://domain.com/app)
next build & next start

The build stage will upload source maps and release files to Sentry “automatically”. This means that new release will appear on the Sentry side.

Then when you deploy/start the app it starts to send an error messages to the Sentry which is fine but then it comes to the “release mismatch”.

If you haven’t defined the release value the Sentry will do that using random values.

So…

The Sentry will create an unique release (inc. src maps) In the build stage.
The Sentry will create an other unique release when the app starts to send an error logs.

→ Release mismatch!

1 Like

Maybe not the optimal solution, but if you’re using the webpack plugin you can set dryRun to true.

For example

// next.config.js
const { withSentryConfig } = require("@sentry/nextjs");

const moduleExports = {
  // opts
};

const sentryWebpackPluginOptions = {
  dryRun: true,
// dryRun: process.env.VERCEL != "1" // for example, do a dryRun in non-Vercel environment
};

module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions);