Skip to content

Commit f9cecf2

Browse files
lforstbillyvg
authored andcommitted
feat(nextjs): Allow for suppressing warning about missing global error handler file (#12369)
1 parent 475f9ce commit f9cecf2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,18 @@ export function constructWebpackConfigFunction(
291291
globalErrorFile => fs.existsSync(path.join(appDirPath!, globalErrorFile)),
292292
);
293293

294-
if (!hasGlobalErrorFile && !showedMissingGlobalErrorWarningMsg) {
294+
if (
295+
!hasGlobalErrorFile &&
296+
!showedMissingGlobalErrorWarningMsg &&
297+
!process.env.SENTRY_SUPPRESS_GLOBAL_ERROR_HANDLER_FILE_WARNING
298+
) {
295299
// eslint-disable-next-line no-console
296300
console.log(
297301
`${chalk.yellow(
298302
'warn',
299303
)} - It seems like you don't have a global error handler set up. It is recommended that you add a ${chalk.cyan(
300304
'global-error.js',
301-
)} 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`,
305+
)} 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)`,
302306
);
303307
showedMissingGlobalErrorWarningMsg = true;
304308
}

0 commit comments

Comments
 (0)