From a3bf938862f54f858458c538596d3fa199da7936 Mon Sep 17 00:00:00 2001 From: Sasha <64744993+r1tsuu@users.noreply.github.com> Date: Thu, 10 Oct 2024 16:10:11 +0300 Subject: [PATCH] chore: do not use withSentryConfig for dev/e2e next config if not needed (#8629) This fixes this error when executing particular e2e test with playwright extension image --- instrumentation.ts | 2 +- next.config.mjs | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/instrumentation.ts b/instrumentation.ts index 41a4d932d..bfbc30551 100644 --- a/instrumentation.ts +++ b/instrumentation.ts @@ -1,5 +1,5 @@ export async function register() { - if (process.env.NEXT_RUNTIME === 'nodejs') { + if (process.env.NEXT_RUNTIME === 'nodejs' && process.env.NEXT_PUBLIC_SENTRY_DSN) { await import('./sentry.server.config.js') } } diff --git a/next.config.mjs b/next.config.mjs index fcaddd3b3..3d865ff7f 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -42,12 +42,21 @@ const config = withBundleAnalyzer( '.mjs': ['.mts', '.mjs'], } + // Ignore sentry warnings when not wrapped with withSentryConfig + webpackConfig.ignoreWarnings = [ + ...(webpackConfig.ignoreWarnings ?? []), + { file: /esm\/platform\/node\/instrumentation.js/ }, + { module: /esm\/platform\/node\/instrumentation.js/ }, + ] + return webpackConfig }, }), ) -export default withSentryConfig(config, { - telemetry: false, - tunnelRoute: '/monitoring-tunnel', -}) +export default process.env.NEXT_PUBLIC_SENTRY_DSN + ? withSentryConfig(config, { + telemetry: false, + tunnelRoute: '/monitoring-tunnel', + }) + : config