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.53.0
Framework Version
14.2.21
Link to Sentry event
https://everest-194.sentry.io/issues/28603450/events/4b675f23fd164b2bb5ac69ac711013f1/
Reproduction Example/SDK Setup
TypeError: Cannot read properties of undefined (reading 'sentry')
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
typedRoutes: true,
serverComponentsExternalPackages: ['sequelize', 'convict']
},
webpack: (config) => {
// eslint-disable-next-line no-param-reassign
config.resolve.alias.canvas = false;
return config;
}
};
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { withSentryConfig } = require('@sentry/nextjs');
module.exports = withSentryConfig(nextConfig, {
org: 'everest-194',
project: 'everest',
silent: !process.env.CI,
widenClientFileUpload: true,
reactComponentAnnotation: {
enabled: true
},
authToken: process.env.SENTRY_AUTH_TOKEN,
tunnelRoute: undefined, // usually /monitoring tried if it fixed the error
hideSourceMaps: true,
sourcemaps: {
disable: true
},
disableLogger: true,
// next three usually not included, just tried if they fixed the error
autoInstrumentAppDirectory: false,
autoInstrumentServerFunctions:false,
autoInstrumentMiddleware: false,
automaticVercelMonitors: false
});
instrumentation.ts
import * as Sentry from '@sentry/nextjs';
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
await import('../sentry.server.config');
}
if (process.env.NEXT_RUNTIME === 'edge') {
await import('../sentry.edge.config');
}
}
export const onRequestError = Sentry.captureRequestError;
sentry.(sever|edge).ts
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "https://f51e82984682dfd3b57cdea384474f53@o4508749268779008.ingest.de.sentry.io/4508750933393488",
tracesSampleRate: 1,
debug: true
});
sentry.client.config.ts
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'https://f51e82984682dfd3b57cdea384474f53@o4508749268779008.ingest.de.sentry.io/4508750933393488',
integrations: [Sentry.replayIntegration()],
tracesSampleRate: 1,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
debug: true
});
middleware.ts
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
const isProtectedRoute = createRouteMatcher([
'/((?!sign-in|sign-up|monitoring|instrumentation|_vercel).*)'
]);
export default clerkMiddleware((auth, req) => {
if (isProtectedRoute(req)) auth().protect();
});
export const config = {
matcher: ['/((?!.*\\..*|_next|_vercel|sentry|monitoring|instrumentation).*)', '/(api|trpc)(.*)']
};
Steps to Reproduce
next build && next start
and every client-side page fails (only on build mode, dev mode works okay)
Expected Result
sentry is found
Actual Result
TypeError: Cannot read properties of undefined (reading 'sentry')
Metadata
Metadata
Assignees
Type
Projects
Status
Waiting for: Product Owner