sentry-javascript: Can't use withSentryConfig because it breaks NextJS
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?
SDK Version
7.70.0
Framework Version
@sentry/nextjs 7.70.0
Link to Sentry event
No response
SDK Setup
next.config
/** @type {import('next').NextConfig} */
const { withSentryConfig } = require('@sentry/nextjs')
const nextConfig = {
reactStrictMode: true,
serverRuntimeConfig: {
buildEnv: process.env.BUILD_ENV
},
publicRuntimeConfig: {
buildEnv: process.env.BUILD_ENV
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**'
}
]
}
}
module.exports = nextConfig
module.exports = withSentryConfig(module.exports, { silent: true })
sentry.client.config.js
import * as Sentry from '@sentry/nextjs'
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN
const SENTRY_ENVIRONMENT = process.env.SENTRY_ENVIRONMENT || process.env.ENVIRONMENT
Sentry.init({
dsn: SENTRY_DSN,
environment: SENTRY_ENVIRONMENT,
tracesSampleRate: 0.1,
debug: false,
replaysOnErrorSampleRate: 0.1,
replaysSessionSampleRate: 0.1,
integrations: [
new Sentry.Replay({
maskAllText: true,
blockAllMedia: true
})
]
})
Steps to Reproduce
- Run
next dev - Console throws an error (see picture below)
Expected Result
Not to break the build
Actual Result
Some comments:
- This error is fixed with version 7.20.1 the problem is that that version is imcompatible with my current Next version next@13.5.1
- If I remove withSentryConfig everything works, but there is some problem with withSentryConfig wrapping the NextJS config
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 26 (11 by maintainers)
The fix was released in version 7.78.0.
@Deliaz Thank you, this greatly helped me understand the issue. I think I know what’s wrong. We are building our polyfills in a weird way (this has been on my todo to fix since like forever) and we are trying to pick up an esm dependency from within CJS-land. I’ll try to fix!
That’s how I ended up here in this thread 😄
p.s. I’ll try to get a problematic repo.
@lforst Okey… I see, yes, this looks like an unfortunate mix between a bad auth config and withSentryConfig wrapper. I’m going to keep trying to integrate Sentry by fixing the next auth. Thanks man for taking a look into!
Thanks guys! @lforst let us know if you have any update on the fix.