Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js Build Time Nearly Doubles After Integrating @sentry/nextjs #15469

Open
3 tasks done
dalnoki opened this issue Feb 24, 2025 · 1 comment
Open
3 tasks done

Next.js Build Time Nearly Doubles After Integrating @sentry/nextjs #15469

dalnoki opened this issue Feb 24, 2025 · 1 comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@dalnoki
Copy link

dalnoki commented Feb 24, 2025

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

^9

Framework Version

Next.js Version: 14.1.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

After integrating @sentry/nextjs into the customer's Next.js project, they noticed a significant increase in build times. The build time consistently jumps from about 21–22 seconds to ~47–60 seconds, despite excluding Sentry Replays. Additionally, it appears the build process is running on a single processor core, leading to slower performance.

Build Time Comparison:
With Sentry:
Install: ~10s
Build: ~47-60s
Without Sentry:
Install: ~7s
Build: ~21-22s

Sentry SDK Configuration:
sentry.client.config.js | sentry.edge.config.js | sentry.server.config.js

all three files are same as below

import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,

// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
});

Calculated build time using following commands -
time npm install
time npm run build

Expected Result

Minimal or no impact on build time after integrating Sentry, or at least a smaller overhead compared to the observed near-doubling in build duration.

Actual Result

Build time increases by over 100% (from ~21–22 seconds to ~47–60 seconds).

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Feb 24, 2025
@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Feb 24, 2025
@lforst
Copy link
Member

lforst commented Feb 24, 2025

Hi, we are aware of this. The reasons for increased build times are:

  • Next.js is generating sourcemaps not ideally efficiency-wise (I believe due to webpack) eating a lot of memory and CPU. Here we cannot do anything from the SDK perspective. As a user, you could disable sourcemap generation but this will drastically reduce UX when using Sentry because you will not be able to see your original source code in issues.
  • Sourcemap upload: We are uploading sourcemaps to Sentry a bit inefficiently and consume a lot of memory. We are in the process of fixing this and it has already improved a lot. I recommend using the most up to date version of the Next.js SDK and @sentry/cli subdependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
Status: No status
Development

No branches or pull requests

2 participants