From 2809a1f8d8a1098aa81886992e026a2214e205dd Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Tue, 27 Jan 2026 14:43:20 -0500 Subject: [PATCH 1/2] fix(nextjs): turn off debug id injection if sourcemaps are explicitly disabled --- packages/nextjs/src/config/handleRunAfterProductionCompile.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nextjs/src/config/handleRunAfterProductionCompile.ts b/packages/nextjs/src/config/handleRunAfterProductionCompile.ts index d5c90962e581..901ba9dffa6e 100644 --- a/packages/nextjs/src/config/handleRunAfterProductionCompile.ts +++ b/packages/nextjs/src/config/handleRunAfterProductionCompile.ts @@ -50,7 +50,8 @@ export async function handleRunAfterProductionCompile( await sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal(); await sentryBuildPluginManager.createRelease(); - if (!usesNativeDebugIds) { + // Skip debug ID injection if sourcemaps are disabled which are only relevant for sourcemap correlation + if (!usesNativeDebugIds && sentryBuildOptions.sourcemaps?.disable !== true) { await sentryBuildPluginManager.injectDebugIds([distDir]); } From da6d53e5a6f411b786eda655b4ef976b00f8d510 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Tue, 27 Jan 2026 14:51:39 -0500 Subject: [PATCH 2/2] test: add test cases --- .../handleRunAfterProductionCompile.test.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/packages/nextjs/test/config/handleRunAfterProductionCompile.test.ts b/packages/nextjs/test/config/handleRunAfterProductionCompile.test.ts index f32eb28ddcfc..2d1769986158 100644 --- a/packages/nextjs/test/config/handleRunAfterProductionCompile.test.ts +++ b/packages/nextjs/test/config/handleRunAfterProductionCompile.test.ts @@ -249,6 +249,62 @@ describe('handleRunAfterProductionCompile', () => { }); }); + describe('sourcemaps disabled', () => { + it('skips debug ID injection when sourcemaps.disable is true', async () => { + const optionsWithDisabledSourcemaps: SentryBuildOptions = { + ...mockSentryBuildOptions, + sourcemaps: { + disable: true, + }, + }; + + await handleRunAfterProductionCompile( + { + releaseName: 'test-release', + distDir: '/path/to/.next', + buildTool: 'turbopack', + }, + optionsWithDisabledSourcemaps, + ); + + expect(mockSentryBuildPluginManager.injectDebugIds).not.toHaveBeenCalled(); + expect(mockSentryBuildPluginManager.uploadSourcemaps).toHaveBeenCalled(); + }); + + it('still injects debug IDs when sourcemaps.disable is false', async () => { + const optionsWithEnabledSourcemaps: SentryBuildOptions = { + ...mockSentryBuildOptions, + sourcemaps: { + disable: false, + }, + }; + + await handleRunAfterProductionCompile( + { + releaseName: 'test-release', + distDir: '/path/to/.next', + buildTool: 'turbopack', + }, + optionsWithEnabledSourcemaps, + ); + + expect(mockSentryBuildPluginManager.injectDebugIds).toHaveBeenCalledWith(['/path/to/.next']); + }); + + it('still injects debug IDs when sourcemaps option is undefined', async () => { + await handleRunAfterProductionCompile( + { + releaseName: 'test-release', + distDir: '/path/to/.next', + buildTool: 'turbopack', + }, + mockSentryBuildOptions, + ); + + expect(mockSentryBuildPluginManager.injectDebugIds).toHaveBeenCalledWith(['/path/to/.next']); + }); + }); + describe('path handling', () => { it('correctly passes distDir to debug ID injection', async () => { const customDistDir = '/custom/dist/path';