Skip to content

NextJS Build hungs.. with sourcemap enabled #16259

Open
@softmarshmallow

Description

@softmarshmallow

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

"@sentry/nextjs": "^9.17.0",

Framework Version

"next": "15.3.2", "react": "19.1.0",

Link to Sentry event

No response

Reproduction Example/SDK Setup

Image

I recently added sentry to my nextjs app.

{
      org: process.env.SENTRY_ORG,
      project: process.env.SENTRY_PROJECT,
      silent: !process.env.CI, // Only print logs for uploading source maps in CI
      widenClientFileUpload: false,
      sourcemaps: {
        disable:
          process.env.NODE_ENV === "development" ||
          process.env.VERCEL_ENV === "preview",
      },

      // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
      // This can increase your server load as well as your hosting bill.
      // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
      // side errors will fail.
      tunnelRoute: "/monitoring",

      // Automatically tree-shake Sentry logger statements to reduce bundle size
      disableLogger: true,

      // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
      // See the following for more information:
      // https://docs.sentry.io/product/crons/
      // https://vercel.com/docs/cron-jobs
      automaticVercelMonitors: true,
    } satisfies SentryBuildOptions

The build speed is almost unusable, I think it's a bug.
As you can see,

  • production -> sourcemap on
  • preview -> sourcemap off

I've turned off the widenClientFileUpload for faster build, which does not resolve the issue.

Before sentry, it was about 5min for build on vercel,

After sentry

  • preview (sourcemap off) takes up to 7min (resonable)
  • production exceeds the max build duration 45min.

The build logs says,.

........
    ~/ff24b331-ad6e-4070-940f-aef956132cf6-274.js.map (debug id ff24b331-ad6e-4070-940f-aef956132cf6)
    ~/fff82f28-0ad6-47e8-8633-da46db4abc42-130.js.map (debug id fff82f28-0ad6-47e8-8633-da46db4abc42)
[@sentry/nextjs - Node.js] Info: Successfully uploaded source maps to Sentry

But after the "[@sentry/nextjs - Node.js] Info: Successfully uploaded source maps to Sentry"

no logs will appear, and hungs for the next 30mins, build fails.

what is happening?

Steps to Reproduce

repo: https://github.com/gridaco/grida (/editor)

pnpm why @sentry/webpack-plugin

pnpm why @sentry/webpack-plugin
Legend: production dependency, optional only, dev only

editor@0.1.0 /Users/softmarshmallow/Documents/Apps/grida/grida/editor (PRIVATE)

dependencies:
@sentry/nextjs 9.17.0
└── @sentry/webpack-plugin 3.3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions