From 2295d34e339051e237fdfd8128906c8025ba3e06 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 3 Sep 2024 10:08:16 +0000 Subject: [PATCH 1/2] feat(nextjs): Emit warning when using turbopack --- packages/nextjs/src/config/withSentryConfig.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/nextjs/src/config/withSentryConfig.ts b/packages/nextjs/src/config/withSentryConfig.ts index 78df524c88c0..4e712fea2501 100644 --- a/packages/nextjs/src/config/withSentryConfig.ts +++ b/packages/nextjs/src/config/withSentryConfig.ts @@ -103,6 +103,15 @@ function getFinalConfigObject( ); } + if (process.env.TURBOPACK && !process.env.SENTRY_SUPPRESS_TURBOPACK_WARNING) { + // eslint-disable-next-line no-console + console.warn( + `[@sentry/nextjs] WARNING: You are using the Sentry SDK with \`next ${ + process.env.NODE_ENV === 'development' ? 'dev' : 'build' + } --turbo\`. The Sentry SDK doesn't yet fully support Turbopack. The SDK will not be loaded in the browser, and serverside instrumentation will be inaccurate or incomplete. Production builds will still fully work. If you are just trying out Sentry or attempting to configure the SDK, we recommend temporarily removing the \`--turbo\` flag while you are developing locally. Follow this issue for progress on Sentry + Turbopack: https://github.com/getsentry/sentry-javascript/issues/8105. (You can suppress this warning by setting SENTRY_SUPPRESS_TURBOPACK_WARNING=1 as environment variable)`, + ); + } + return { ...incomingUserNextConfigObject, webpack: constructWebpackConfigFunction(incomingUserNextConfigObject, userSentryOptions), From 440e09a1ac97676acc3d98b61c8010689c866ae6 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 3 Sep 2024 12:16:23 +0000 Subject: [PATCH 2/2] Only say "prod builds will work" when it is a non-prod turbo build. --- packages/nextjs/src/config/withSentryConfig.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nextjs/src/config/withSentryConfig.ts b/packages/nextjs/src/config/withSentryConfig.ts index 4e712fea2501..e87cbf11ce44 100644 --- a/packages/nextjs/src/config/withSentryConfig.ts +++ b/packages/nextjs/src/config/withSentryConfig.ts @@ -108,7 +108,9 @@ function getFinalConfigObject( console.warn( `[@sentry/nextjs] WARNING: You are using the Sentry SDK with \`next ${ process.env.NODE_ENV === 'development' ? 'dev' : 'build' - } --turbo\`. The Sentry SDK doesn't yet fully support Turbopack. The SDK will not be loaded in the browser, and serverside instrumentation will be inaccurate or incomplete. Production builds will still fully work. If you are just trying out Sentry or attempting to configure the SDK, we recommend temporarily removing the \`--turbo\` flag while you are developing locally. Follow this issue for progress on Sentry + Turbopack: https://github.com/getsentry/sentry-javascript/issues/8105. (You can suppress this warning by setting SENTRY_SUPPRESS_TURBOPACK_WARNING=1 as environment variable)`, + } --turbo\`. The Sentry SDK doesn't yet fully support Turbopack. The SDK will not be loaded in the browser, and serverside instrumentation will be inaccurate or incomplete. ${ + process.env.NODE_ENV === 'development' ? 'Production builds without `--turbo` will still fully work. ' : '' + }If you are just trying out Sentry or attempting to configure the SDK, we recommend temporarily removing the \`--turbo\` flag while you are developing locally. Follow this issue for progress on Sentry + Turbopack: https://github.com/getsentry/sentry-javascript/issues/8105. (You can suppress this warning by setting SENTRY_SUPPRESS_TURBOPACK_WARNING=1 as environment variable)`, ); }