From 3cc935977a432c41ff0872e014bf30fad5103641 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 30 Jul 2024 12:45:04 +0000 Subject: [PATCH 1/2] fix(nextjs): Only delete clientside bundle source maps with `sourcemaps.deleteFilesAfterUpload` --- packages/nextjs/src/config/webpackPluginOptions.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/nextjs/src/config/webpackPluginOptions.ts b/packages/nextjs/src/config/webpackPluginOptions.ts index 6b755cf2c839..f70862bfe484 100644 --- a/packages/nextjs/src/config/webpackPluginOptions.ts +++ b/packages/nextjs/src/config/webpackPluginOptions.ts @@ -76,9 +76,12 @@ export function getWebpackPluginOptions( ignore: sentryBuildOptions.sourcemaps?.ignore ?? sourcemapUploadIgnore, filesToDeleteAfterUpload: sentryBuildOptions.sourcemaps?.deleteSourcemapsAfterUpload ? [ - path.join(distDirAbsPath, '**', '*.js.map'), - path.join(distDirAbsPath, '**', '*.mjs.map'), - path.join(distDirAbsPath, '**', '*.cjs.map'), + // We only care to delete client bundle source maps because they would be the ones being served. + // Removing the server source maps crashes Vercel builds for (thus far) unknown reasons: + // https://github.com/getsentry/sentry-javascript/issues/13099 + path.join(distDirAbsPath, 'static', '**', '*.js.map'), + path.join(distDirAbsPath, 'static', '**', '*.mjs.map'), + path.join(distDirAbsPath, 'static', '**', '*.cjs.map'), ] : undefined, ...sentryBuildOptions.unstable_sentryWebpackPluginOptions?.sourcemaps, From a57e53b7dac2a49a7bc69b7c8ee1368b5221aca0 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 30 Jul 2024 13:46:13 +0000 Subject: [PATCH 2/2] Update test --- .../test-applications/nextjs-app-dir/assert-build.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts index 58453223a4cb..955988101724 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts @@ -22,10 +22,10 @@ assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[\.\.\.parame assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[parameter\]/); // Read the contents of the directory -const files = fs.readdirSync(path.join(process.cwd(), '.next', 'server')); +const files = fs.readdirSync(path.join(process.cwd(), '.next', 'static')); const mapFiles = files.filter(file => path.extname(file) === '.map'); if (mapFiles.length > 0) { - throw new Error('.map files found even though `sourcemaps.deleteSourcemapsAfterUpload` option is set!'); + throw new Error('Client bundle .map files found even though `sourcemaps.deleteSourcemapsAfterUpload` option is set!'); } export {};