NextJS SSG Error Handling Not Working, Client-side does #6254
-
| I'm struggling a lot to understand why the server-side error handling isn't working. We have had client side working for quite some time, I'm not sure if server side has ever worked for us (so, I can't point specifically to something we maybe changed as a clue). Versions: I made a testing page that will throw either in when I run it locally with note that comes from the import * as Sentry from '@sentry/nextjs'; const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; Sentry.init({ dsn: SENTRY_DSN, environment: process.env.ACTIVE_ENV, tracesSampleRate: 1.0, debug: true, beforeSend: (e) => { console.log('Sentry: should send'); return e; }, });Relevant parts of the next config looks like const { formatInTimeZone } = require('date-fns-tz'); const { withSentryConfig } = require('@sentry/nextjs'); const ENVIRONMENTS = { DEV: 'dev', STAGE: 'staging', PROD: 'production', }; const nextjsEnvironment = process.env.ACTIVE_ENV; let ENVIRONMENT; if (nextjsEnvironment === ENVIRONMENTS.STAGE) { ENVIRONMENT = ENVIRONMENTS.STAGE; } else if (nextjsEnvironment === ENVIRONMENTS.PROD) { ENVIRONMENT = ENVIRONMENTS.PROD; } else { ENVIRONMENT = ENVIRONMENTS.DEV; } const isDev = nextjsEnvironment !== ENVIRONMENTS.STAGE && nextjsEnvironment !== ENVIRONMENTS.PROD; const isProd = nextjsEnvironment === ENVIRONMENTS.PROD; const SITE_URL = process.env.SITE_URL || process.env.URL || process.env.DEPLOY_URL || 'https://oursite'; const BRANCH = process.env.VERCEL_GIT_COMMIT_REF || process.env.BRANCH || 'unset'; const possibleCommitRef = process.env.VERCEL_GIT_COMMIT_SHA || process.env.COMMIT_REF || '000000'; const COMMIT_REF = possibleCommitRef.slice(0, 6); const now = new Date(); const BUILD_DATETIME_HUMAN = formatInTimeZone( now, 'America/Chicago', `EEE. MMMM d, yyyy, K:mm aa 'Central'` ); const SentryWebpackPluginOptions = { silent: false, debug: true, }; /** * @type {import('next').NextConfig} */ const nextConfig = { swcMinify: true, reactStrictMode: true, trailingSlash: false, productionBrowserSourceMaps: true, images: { domains: ['cdn.sanity.io'], // disableStaticImages: true, }, // These vars are injected at build time, and are accessible as `process.env.KEY` in site code env: { BRANCH: BRANCH, COMMIT_REF: COMMIT_REF, BUILD_DATETIME_HUMAN: BUILD_DATETIME_HUMAN, ACTIVE_ENV: ENVIRONMENT, SITE_URL: SITE_URL, SANITY_PROJECT_ID: process.env.SANITY_PROJECT_ID, SANITY_DATASET: process.env.SANITY_DATASET, SANITY_READ_TOKEN: process.env.SANITY_READ_TOKEN || '', THEMIS_URL: process.env.THEMIS_URL || 'https://example.com/graphql', GIT_REF: process.env.COMMIT_REF, SENTRY_DSN: process.env.SENTRY_DSN, FATHOM_SITE_ID: process.env.FATHOM_SITE_ID, MAPBOX_TOKEN: process.env.MAPBOX_TOKEN, ENVIRONMENTS: ENVIRONMENTS, IS_PROD: isProd, }, eslint: { // We check in CI, so this is duplicate effort: https://nextjs.org/docs/api-reference/next.config.js/ignoring-eslint ignoreDuringBuilds: true, }, webpack: (config, options) => { config.module.rules.push({ test: /\.svg$/, use: [ options.defaultLoaders.babel, { loader: '@svgr/webpack', options: { babel: false }, }, ], }); return config; }, }; module.exports = withSentryConfig(nextConfig, SentryWebpackPluginOptions); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
| Created #6255 to track this here - let's figure out why this isn't working! |
Beta Was this translation helpful? Give feedback.
Created #6255 to track this here - let's figure out why this isn't working!