diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 44537ede59f8..e529a2b47f57 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -291,14 +291,18 @@ export function constructWebpackConfigFunction( globalErrorFile => fs.existsSync(path.join(appDirPath!, globalErrorFile)), ); - if (!hasGlobalErrorFile && !showedMissingGlobalErrorWarningMsg) { + if ( + !hasGlobalErrorFile && + !showedMissingGlobalErrorWarningMsg && + !process.env.SENTRY_SUPPRESS_GLOBAL_ERROR_HANDLER_FILE_WARNING + ) { // eslint-disable-next-line no-console console.log( `${chalk.yellow( 'warn', )} - It seems like you don't have a global error handler set up. It is recommended that you add a ${chalk.cyan( 'global-error.js', - )} file with Sentry instrumentation so that React rendering errors are reported to Sentry. Read more: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#react-render-errors-in-app-router`, + )} file with Sentry instrumentation so that React rendering errors are reported to Sentry. Read more: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#react-render-errors-in-app-router (you can suppress this warning by setting SENTRY_SUPPRESS_GLOBAL_ERROR_HANDLER_FILE_WARNING=1 as environment variable)`, ); showedMissingGlobalErrorWarningMsg = true; }