Skip to content

[Nextjs] withSentryConfig injects debugId despite source maps: { disabled: true } #15106

Closed

Description

@digitalhank

Environment

self-hosted (https://develop.sentry.dev/self-hosted/)

Steps to Reproduce

using "@sentry/nextjs": "8.47.0", "@sentry/cli": "2.39.1", "@sentry/webpack-plugin": "2.22.7", "next": "14.1.4".

We are employing a micro frontend strategy with nextjs and module federation. As per your documentation on micro frontends, only host is using "@sentry/nextjs" w/ instrumentation while the remotes are using "@sentry/webpack-plugin" in the next.config in order to propagate errors to the appropriate micro frontend project.

Our CI pipeline is restrictive and stops us from uploading source maps to sentry in the same job we build the app docker image. This has lead me to separate the jobs like

Job 1 - Build the app with source maps and inject debug id using the sentry-cli sourcemaps inject. Pass source maps to job 2.
Job 2 - Upload source maps to sentry using sentry-cli source maps upload

Initially I was doing this with one of the remotes that uses sentry/webpack-plugin. Sentry was struggling to map the debug id in the uploaded artifact with the stack trace in the error event. I realized that during build, if we disable source maps in the next.config and let the cli tool do all the work, the debug id are correctly mapped.

    sentryWebpackPlugin({
      sourcemaps: {
        disable: true,
      },
      moduleMetadata: ({ release }) => ({
        dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
        release,
      }),
    }),

The problem: disabling source maps in withSentryConfig from @sentry/nextjs does not have the same effect. debug id are still injected which confuses the sentry engine because a single file can contain both the debug id injected during build and the one injected after build by the cli.

Edit - using "unstable_sentryWebpackPluginOptions" in "withSentryConfig" is a viable workaround

Expected Result

There should be no debug id reference in any file

Actual Result

files (like _app) contain debugid in one of the first lines

Product Area

Issues - Source Maps

Link

No response

DSN

No response

Version

24.8.0

Activity

  1. getsantry commented on Dec 31, 2024

    @getsantry

    Assigning to @getsentry/support for routing ⏲️

  2. transferred this issue fromgetsentry/sentryon Jan 2, 2025
  3. Lms24 commented on Jan 21, 2025

    @Lms24
    Member

    Hi @digitalhank

    disabling source maps in withSentryConfig from @sentry/nextjs does not have the same effect

    can you show us how you did this specifically? Usually you should be good with using withSentryConfig without separately installing the @sentry/webpack-plugin.

    Also, I'm gonna transfer this issue to our JS SDK repo as this seems like an SDK-related problem as of now.

  4. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jan 21, 2025
  5. Lms24 commented on Jan 21, 2025

    @Lms24
    Member

    Hey, one more update: We identified the problem in withSentryConfig and we'll fix it in v9 of the SDK.

    Generally, injecting debugIds rarely is a problem, even if you don't upload source maps. You're the first one reporting this and arguably your build setup is fairly special compared to a default NextJS build. Which is why this wasn't surfaced before.

    Thanks for reporting this!

  6. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jan 21, 2025
  7. digitalhank commented on Jan 21, 2025

    @digitalhank
    Author

    I’ve been on vacation. Thanks for fixing the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions