-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
"@sentry/nextjs": "^10.29.0",
Framework Version
"next": "^15.5.7",
Link to Sentry event
No response
Reproduction Example/SDK Setup
Monolithic application and we use next.js.
Dev environment. For compilation, we just use npm run build of next.js where it runs next build. But for development, we use npm run dev that runs next dev --experimental-https
For our sentry.server.config.ts, we use this code:
// This file configures the initialization of Sentry on the server.
// The config you add here will be used whenever the server handles a request.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import { init } from "@sentry/nextjs";
const isProduction = process.env.NODE_ENV === "production";
// Use environment-specific DSN if available, otherwise fall back to default
const sentryDsn =
process.env.SENTRY_DSN ||
"DSN_HERE";
init({
dsn: sentryDsn,
// Set the environment
environment: process.env.NODE_ENV || "development",
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: isProduction ? 0.1 : 1, // Lower sampling in production
// Enable logs to be sent to Sentry
enableLogs: true,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: !isProduction,
// Add release information
release: process.env.VERCEL_GIT_COMMIT_SHA || "development",
// Add tags for better filtering
initialScope: {
tags: {
environment: process.env.NODE_ENV || "development",
deployment: process.env.VERCEL_ENV || "local",
},
},
// Only enable Sentry in production or when explicitly enabled
enabled: isProduction || process.env.ENABLE_SENTRY === "true",
});we also capture all thrown exception with our global-error.ts
"use client";
import { captureException } from "@sentry/nextjs";
import NextError from "next/error";
import { useEffect } from "react";
export default function GlobalError({
error,
}: {
error: Error & { digest?: string };
}) {
useEffect(() => {
captureException(error);
}, [error]);
return (
<html>
<body>
{/* `NextError` is the default Next.js error page component. Its type
definition requires a `statusCode` prop. However, since the App Router
does not expose status codes for errors, we simply pass 0 to render a
generic error message. */}
<NextError statusCode={0} />
</body>
</html>
);
}Steps to Reproduce
See above
Expected Result
Compilation time is about 2 seconds.
Actual Result
we identified our local environment was very slow due to the fact that we had to compile thousands of modules every time we do load a page. We identfied that removing sentry from our code base was speeding up significantly. The difference between the attached files is we had once sentry installed and once sentry completely removed from the code base. Using environment variables didn't help here.
Without Sentry:
With Sentry:
Additional Context
This is an escalation from Zendesk for the customer. Original ticket and their package.json are provided in the connected Linear issue.
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
Status