Skip to content

fix(nuxt): Delete source maps after Nitro finishes building - #23407

Open
s1gr1d wants to merge 1 commit into
developfrom
sig/nuxt-sourcemap-deletion
Open

fix(nuxt): Delete source maps after Nitro finishes building#23407
s1gr1d wants to merge 1 commit into
developfrom
sig/nuxt-sourcemap-deletion

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Aug 13, 2026

Copy link
Copy Markdown
Member

Defer source map deletion until Nuxt’s close hook, after Nitro has copied public assets into the final output directory.

Root cause

The Vite plugin previously deleted source maps from Nuxt’s intermediate client build output. Nitro subsequently copied those assets into the final output, causing the source maps to reappear.

The Vite and Rollup plugins continue to inject debug IDs and upload source maps, but receive options with deletion disabled. Once the complete Nuxt build finishes, the Nuxt integration uses the bundler plugin manager to delete artifacts.

Closes #22801

@s1gr1d
s1gr1d requested a review from a team as a code owner August 13, 2026 14:11
@s1gr1d
s1gr1d requested review from chargome and mydea and removed request for a team August 13, 2026 14:11
Comment on lines +107 to +110
nuxt.hook('close', async () => {
if (sourceMapsEnabled && !nuxt.options.dev && !nuxt.options?._prepare) {
await deleteSourceMapsAfterBuild(getPluginOptions(moduleOptions, shouldDeleteFilesFallback));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Source maps are incorrectly deleted when sourcemaps.disable is set to 'disable-upload', preventing manual uploads.
Severity: MEDIUM

Suggested Fix

Update the condition in the close hook to also check if moduleOptions.sourcemaps?.disable is not equal to 'disable-upload'. This will ensure that the source map deletion logic is skipped when this specific setting is used, aligning the behavior with its intended purpose.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/nuxt/src/vite/sourceMaps.ts#L107-L110

Potential issue: When the `sourcemaps.disable` option is set to the string
`'disable-upload'`, the source maps are still deleted after the build process concludes.
The check `moduleOptions.sourcemaps?.disable !== true` in the `close` hook evaluates to
true in this case, which incorrectly triggers the source map deletion logic. This
prevents users from manually uploading the source maps, which is the intended purpose of
the `'disable-upload'` setting. The `deleteArtifacts` function proceeds to delete the
files without any further checks on the `disable` option's value.

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.3 kB - -
@sentry/browser - with treeshaking flags 28.47 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.81 kB - -
@sentry/browser (incl. Tracing) 48.58 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.59 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.46 kB - -
@sentry/browser (incl. Tracing, Replay) 87.98 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.36 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.7 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.39 kB - -
@sentry/browser (incl. Feedback) 47.65 kB - -
@sentry/browser (incl. sendFeedback) 35.13 kB - -
@sentry/browser (incl. FeedbackAsync) 40.28 kB - -
@sentry/browser (incl. Metrics) 31.24 kB - -
@sentry/browser (incl. Logs) 31.52 kB - -
@sentry/browser (incl. Metrics & Logs) 32.15 kB - -
@sentry/react 32.09 kB - -
@sentry/react (incl. Tracing) 50.77 kB - -
@sentry/vue 35.34 kB - -
@sentry/vue (incl. Tracing) 50.54 kB - -
@sentry/svelte 30.33 kB - -
CDN Bundle 31.61 kB - -
CDN Bundle (incl. Tracing) 48.89 kB - -
CDN Bundle (incl. Logs, Metrics) 33.8 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.82 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.31 kB - -
CDN Bundle (incl. Tracing, Replay) 86.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.31 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.18 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.12 kB - -
CDN Bundle - uncompressed 93.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.74 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.08 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.7 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.37 kB - -
@sentry/nextjs (client) 53.29 kB - -
@sentry/sveltekit (client) 49 kB - -
@sentry/core/server 65.37 kB - -
@sentry/core/browser 51.7 kB - -
@sentry/node 117.14 kB -0.01% -1 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 81.43 kB - -
@sentry/aws-serverless 90.92 kB -0.01% -1 B 🔽
@sentry/cloudflare (withSentry) - minified 213.99 kB - -
@sentry/cloudflare (withSentry) 528.92 kB - -

View base workflow run

@chargome chargome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nuxt: filesToDeleteAfterUpload does not delete file after build

2 participants