Closed
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
8.37.1
Framework Version
Next 15.0.2
Link to Sentry event
No response
Reproduction Example/SDK Setup
// sentry.client.config.js
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "DSN HERE",
// Replay may only be enabled for the client-side
integrations: [Sentry.replayIntegration()],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: true,
});
// next.config.ts
async function config(phase, { defaultConfig }) : Promise<NextConfig> {
return
{
pageExtensions: ["js", "jsx", "tsx", "ts"],
output: "standalone",
experimental: {
// Reduces bundle size
fallbackNodePolyfills: false,
}
}
}
module.exports = withSentryConfig(
config,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
org: "ORG",
project: "PROJECT",
// Only print logs for uploading source maps in CI
silent: !process.env.CI,
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Automatically annotate React components to show their full name in breadcrumbs and session replay
reactComponentAnnotation: {
enabled: true,
},
// 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",
// Hides source maps from generated client bundles
hideSourceMaps: true,
// 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: false,
}
);
Steps to Reproduce
- Run
next dev
with the config above - See an error
TypeError: process.env is undefined
- Remove
fallbackNodePolyfills
- Run
next dev
- No error occurs
Expected Result
- You can run the Sentry NextJS SDK without polyfilling
process.env
Actual Result
node_modules/@sentry/nextjs/build/cjs/client/index.js
'sinit
function has multiple calls toprocess.env
and assumes a polyfill.
Metadata
Metadata
Assignees
Type
Projects
Status
No status