From 8cbf27384b985b4ddfde4e4cbf7125eb2b7127f2 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 13 Oct 2026 10:28:32 +0200 Subject: [PATCH 1/2] fix(astro): Delete generated source maps for static output When the SDK enables hidden source maps, it deletes them after upload with `./dist/**/client/**/*.map` and `./dist/**/server/**/*.map`. Static output has neither folder and writes client assets to `/_astro`, so the maps stayed in `dist` and got deployed. Also delete maps in the `build.assets` folder. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../astro-7-sourcemaps/assert-build.ts | 5 +--- packages/astro/src/integration/index.ts | 9 +++++-- packages/astro/test/integration/index.test.ts | 24 +++++++++++++++---- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/astro-7-sourcemaps/assert-build.ts b/dev-packages/e2e-tests/test-applications/astro-7-sourcemaps/assert-build.ts index 37f5626e9ad0..aeb76ee19e32 100644 --- a/dev-packages/e2e-tests/test-applications/astro-7-sourcemaps/assert-build.ts +++ b/dev-packages/e2e-tests/test-applications/astro-7-sourcemaps/assert-build.ts @@ -92,9 +92,6 @@ for (const outputDir of OUTPUT_DIRS) { } // The app does not set `build.sourcemap`, so the SDK enables hidden maps and must delete them after upload. -// TODO: The default `filesToDeleteAfterUpload` globs miss static output, which writes maps to `dist/_astro`. -if (!isStatic) { - assert.deepEqual(findSourceMapFiles({ outputDir: BUILD_OUTPUT }), [], `Expected no source maps in ${BUILD_OUTPUT}`); -} +assert.deepEqual(findSourceMapFiles({ outputDir: BUILD_OUTPUT }), [], `Expected no source maps in ${BUILD_OUTPUT}`); console.log('All sourcemap assertions passed!'); diff --git a/packages/astro/src/integration/index.ts b/packages/astro/src/integration/index.ts index 2d4ae0c152cb..eaf9e48fef10 100644 --- a/packages/astro/src/integration/index.ts +++ b/packages/astro/src/integration/index.ts @@ -71,8 +71,13 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { typeof sourcemaps?.filesToDeleteAfterUpload === 'undefined' && computedSourceMapSettings.previousUserSourceMapSetting === 'unset' ) { - // This also works for adapters, as the source maps are also copied to e.g. the .vercel folder - updatedFilesToDeleteAfterUpload = ['./dist/**/client/**/*.map', './dist/**/server/**/*.map']; + // This also works for adapters, as the source maps are also copied to e.g. the .vercel folder. + // Static output has no client folder and writes client assets to `/` instead. + updatedFilesToDeleteAfterUpload = [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + `./dist/**/${config.build?.assets ?? '_astro'}/**/*.map`, + ]; debug && logger.info( diff --git a/packages/astro/test/integration/index.test.ts b/packages/astro/test/integration/index.test.ts index 19a272db17a7..2381cecd53bc 100644 --- a/packages/astro/test/integration/index.test.ts +++ b/packages/astro/test/integration/index.test.ts @@ -112,7 +112,11 @@ describe('sentryAstro integration', () => { bundleSizeOptimizations: {}, sourcemaps: { assets: ['out/**/*', 'out/**/.prerender/**/*'], - filesToDeleteAfterUpload: ['./dist/**/client/**/*.map', './dist/**/server/**/*.map'], + filesToDeleteAfterUpload: [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + './dist/**/_astro/**/*.map', + ], }, _metaOptions: { telemetry: { @@ -143,7 +147,11 @@ describe('sentryAstro integration', () => { bundleSizeOptimizations: {}, sourcemaps: { assets: ['dist/**/*', 'dist/**/.prerender/**/*'], - filesToDeleteAfterUpload: ['./dist/**/client/**/*.map', './dist/**/server/**/*.map'], + filesToDeleteAfterUpload: [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + './dist/**/_astro/**/*.map', + ], }, _metaOptions: { telemetry: { @@ -182,7 +190,11 @@ describe('sentryAstro integration', () => { bundleSizeOptimizations: {}, sourcemaps: { assets: ['{.vercel,dist}/**/*', '{.vercel,dist}/**/.prerender/**/*'], - filesToDeleteAfterUpload: ['./dist/**/client/**/*.map', './dist/**/server/**/*.map'], + filesToDeleteAfterUpload: [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + './dist/**/_astro/**/*.map', + ], }, _metaOptions: { telemetry: { @@ -221,7 +233,11 @@ describe('sentryAstro integration', () => { bundleSizeOptimizations: {}, sourcemaps: { assets: ['dist/server/**/*, dist/client/**/*'], - filesToDeleteAfterUpload: ['./dist/**/client/**/*.map', './dist/**/server/**/*.map'], + filesToDeleteAfterUpload: [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + './dist/**/_astro/**/*.map', + ], }, _metaOptions: { telemetry: { From 7af7d56fb48de7ebf585fcc1d8c247bec6b9a976 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 13 Oct 2026 11:31:15 +0200 Subject: [PATCH 2/2] fix(astro): Delete source maps in the prerender folder after upload Astro removes the hidden `.prerender` folder at the end of the build, so these maps don't end up in the output today. Delete them ourselves anyway, so we don't rely on Astro internals for maps the SDK turned on. Co-Authored-By: Claude Opus 5.5 (1M context) --- packages/astro/src/integration/index.ts | 2 ++ packages/astro/test/integration/index.test.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/packages/astro/src/integration/index.ts b/packages/astro/src/integration/index.ts index eaf9e48fef10..b4e54545a8d3 100644 --- a/packages/astro/src/integration/index.ts +++ b/packages/astro/src/integration/index.ts @@ -73,10 +73,12 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { ) { // This also works for adapters, as the source maps are also copied to e.g. the .vercel folder. // Static output has no client folder and writes client assets to `/` instead. + // Astro removes the hidden `.prerender` folder itself, but we don't want to rely on that. updatedFilesToDeleteAfterUpload = [ './dist/**/client/**/*.map', './dist/**/server/**/*.map', `./dist/**/${config.build?.assets ?? '_astro'}/**/*.map`, + './dist/**/.prerender/**/*.map', ]; debug && diff --git a/packages/astro/test/integration/index.test.ts b/packages/astro/test/integration/index.test.ts index 2381cecd53bc..54b199086c7c 100644 --- a/packages/astro/test/integration/index.test.ts +++ b/packages/astro/test/integration/index.test.ts @@ -116,6 +116,7 @@ describe('sentryAstro integration', () => { './dist/**/client/**/*.map', './dist/**/server/**/*.map', './dist/**/_astro/**/*.map', + './dist/**/.prerender/**/*.map', ], }, _metaOptions: { @@ -151,6 +152,7 @@ describe('sentryAstro integration', () => { './dist/**/client/**/*.map', './dist/**/server/**/*.map', './dist/**/_astro/**/*.map', + './dist/**/.prerender/**/*.map', ], }, _metaOptions: { @@ -194,6 +196,7 @@ describe('sentryAstro integration', () => { './dist/**/client/**/*.map', './dist/**/server/**/*.map', './dist/**/_astro/**/*.map', + './dist/**/.prerender/**/*.map', ], }, _metaOptions: { @@ -237,6 +240,7 @@ describe('sentryAstro integration', () => { './dist/**/client/**/*.map', './dist/**/server/**/*.map', './dist/**/_astro/**/*.map', + './dist/**/.prerender/**/*.map', ], }, _metaOptions: {