Skip to content

feat(nextjs): Support sourcemaps.upload, injectDebugIds and delete - #26337

Merged
timfish merged 12 commits into
developfrom
feat/nextjs-delete-sourcemaps-after-upload
Nov 24, 2026
Merged

timfish merged 12 commits into
developfrom
feat/nextjs-delete-sourcemaps-after-upload

Conversation

@timfish

@timfish timfish commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

On webpack, the SDK no longer deletes client maps with its own static/**/*.map globs. The client compiler passes deleteSourcemapsAfterUpload and sdkEnabledSourceMaps to the bundler plugin. The plugin then removes every JS and CSS map of the client build, also when no upload runs. Server and edge maps stay. Turbopack and useRunAfterProductionCompileHook keep their globs.

The SDK also supports sourcemaps.upload, injectDebugIds and delete. delete applies to client maps only and keeps the Next.js default: client maps are removed on webpack, and on Turbopack when the SDK turned them on. With upload: false or injectDebugIds: false, only delete: true removes maps. The plugin does not get delete, because it would also remove the server maps. With the source map setting unset, Sentry turns on maps only when it uploads them or when delete: false keeps them.

Fixes:

  • Removed visible client maps no longer leave sourceMappingURL comments that point at missing files. The plugin switches them to hidden maps.

Other behaviour changes:

  • Client maps are no longer written to disk and then deleted in afterEmit, so a plugin that reads them from disk after emit finds none.
  • With delete: true, a user's filesToDeleteAfterUpload runs next to the SDK's deletion. Without delete, it still replaces it.
  • withSentryConfig warns about conflicting source map options, because the plugin does not get delete or the user's deleteSourcemapsAfterUpload.

Still open:

  • On Turbopack with useRunAfterProductionCompileHook: false, the SDK turns on productionBrowserSourceMaps and nothing uploads or deletes them.
  • On webpack, the SDK replaces a falsy devtool, because it cannot tell a user's false from the Next.js default.
  • On Turbopack, rewriteSources and moduleMetadata are never applied.

E2E: the apps now include CSS and check for sourceMappingURL comments. nextjs-sourcemaps gets "delete option" and "manual upload" variants for Turbopack and webpack.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 1ea02f0 (PR test merge using develop at 33ae1de)

Against: 33ae1de (develop) · base run #67697

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.54 kB - -
@sentry/browser - with treeshaking flags 28.73 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.6 kB - -
@sentry/browser (incl. Tracing) 53.67 kB - -
@sentry/browser (incl. Tracing Core) 40.59 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 53.67 kB - -
@sentry/browser (incl. Tracing, Profiling) 56.57 kB - -
@sentry/browser (incl. Tracing, Replay) 93.54 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 82.41 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.93 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 111.45 kB - -
@sentry/browser (incl. Feedback) 48.49 kB - -
@sentry/browser (incl. sendFeedback) 31.11 kB - -
@sentry/browser (incl. FeedbackAsync) 36.17 kB - -
@sentry/browser (incl. Metrics) 31.86 kB - -
@sentry/browser (incl. Logs) 32.13 kB - -
@sentry/browser (incl. Metrics & Logs) 32.8 kB - -
@sentry/react 32.56 kB - -
@sentry/react (incl. Tracing) 56.38 kB - -
@sentry/vue 38.75 kB - -
@sentry/vue (incl. Tracing) 56.68 kB - -
@sentry/svelte 30.57 kB - -
@sentry/effect (client) 42.25 kB - -
@sentry/effect (client, incl. Tracing) 49.41 kB - -
@sentry/effect (client, incl. Tracing, Logs, Metrics) 59.3 kB - -
@sentry/remix (Remix 3 client bundle) 59.39 kB - -
CDN Bundle 32.54 kB - -
CDN Bundle (incl. Tracing) 54.15 kB - -
CDN Bundle (incl. Logs, Metrics) 35.27 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 56.63 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.16 kB - -
CDN Bundle (incl. Tracing, Replay) 91.89 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 94.43 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.35 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.81 kB - -
CDN Bundle - uncompressed 94.92 kB - -
CDN Bundle (incl. Tracing) - uncompressed 160.25 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 103.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 167.88 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 233.5 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 280.54 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 288.17 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.47 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 300.09 kB - -
@sentry/nextjs (client) 60.09 kB - -
@sentry/sveltekit (client) 55.03 kB - -
@sentry/core/server 45.83 kB - -
@sentry/core/browser 14.46 kB - -
@sentry/node 156.29 kB -0.01% -1 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.45 kB - -
@sentry/node - without tracing 89.23 kB -0.01% -5 B 🔽
@sentry/node - without channel injection 145.21 kB -0.01% -5 B 🔽
@sentry/aws-serverless 99.87 kB -0.01% -3 B 🔽
@sentry/cloudflare (withSentry) - minified 210.54 kB - -
@sentry/cloudflare (withSentry) 488.88 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 213.49 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 235.78 kB - -

View base workflow run

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 2 not successful, 67 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Failing after 1m Details
❌ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Failing after 1m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 50s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Successful in 54s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 29s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry (static trace lifecycle) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E express-5 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E node-eve (content off) Test (optional) Successful in 58s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 33s Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 33s Details
✅ CI: Optional E2E Tests / E2E express-5 (cloudflare) Test (optional) Successful in 54s Details
✅ CI: Optional E2E Tests / E2E node-eve (0.x) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 55s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (cloudflare) Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (deno) Test (optional) Successful in 53s Details
✅ CI: Optional E2E Tests / E2E astro-7 (static trace lifecycle) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E express-5 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-4-sourcemaps (Vite server) Test (optional) Successful in 32s Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel (cloudflare) Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 (MCP SDK OpenTelemetry) Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (no upload) Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-cloudflare Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E solid-2-ssr (cloudflare) Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 42s Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps enabled by Sentry) Test (optional) Successful in 41s Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vinext-cf-workers (workers cache) Test (optional) Successful in 40s Details

@timfish
timfish force-pushed the feat/nextjs-delete-sourcemaps-after-upload branch from 2de614c to b5b1f4d Compare November 13, 2026 11:35
Base automatically changed from feat/bundler-plugins-delete-without-upload to develop November 13, 2026 13:49
@timfish
timfish force-pushed the feat/nextjs-delete-sourcemaps-after-upload branch from b5b1f4d to 7af6213 Compare November 13, 2026 13:53
@timfish
timfish marked this pull request as ready for review November 13, 2026 17:36
@timfish
timfish requested a review from a team November 13, 2026 17:36
@timfish timfish changed the title feat(nextjs): Remove client source maps with the webpack plugin's deleteSourcemapsAfterUpload feat(nextjs): Delete source maps through the bundler plugin instead of globs Nov 14, 2026
@timfish
timfish marked this pull request as draft November 16, 2026 16:47
…leteSourcemapsAfterUpload`

The webpack client compiler no longer gets the `static/**/*.map` globs. It passes the SDK's `deleteSourcemapsAfterUpload` to the plugin instead, with `true` as the default. A user's own `filesToDeleteAfterUpload` is passed through and replaces this deletion, as before, so the plugin then gets `false`. Whenever the client deletes, it also passes `sdkEnabledSourceMaps`, so the plugin removes every JS and CSS map of the client build: those the SDK turned on and those the user turned on with `productionBrowserSourceMaps` or `devtool`, also of chunks outside the upload globs and also when no upload runs. Server and edge compilers get `false`, so their maps stay as before. Turbopack and `useRunAfterProductionCompileHook` builds keep the globs.

The E2E apps now import a CSS file and also check `.next/static` for `sourceMappingURL` comments in JS and CSS.
@timfish
timfish force-pushed the feat/nextjs-delete-sourcemaps-after-upload branch from 7af6213 to 0cd6ffa Compare November 17, 2026 22:14
@timfish
timfish changed the base branch from develop to feat/core-sourcemap-options November 18, 2026 13:18
@timfish timfish changed the title feat(nextjs): Delete source maps through the bundler plugin instead of globs feat(nextjs): Support sourcemaps.upload, injectDebugIds and delete Nov 18, 2026
@timfish
timfish force-pushed the feat/core-sourcemap-options branch from a3aed62 to 36f613c Compare November 18, 2026 17:20
Base automatically changed from feat/core-sourcemap-options to develop November 19, 2026 09:53
@timfish
timfish marked this pull request as ready for review November 19, 2026 13:29
sourcemaps: {
disable: skipSourcemapsUpload ? true : (sentryBuildOptions.sourcemaps?.disable ?? false),
...getSourceMapFeatureOptions(userSourcemaps, skipSourcemapsUpload),
// `sourcemaps.delete` does not reach the plugin, which would also remove the server source maps.

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.

Since delete isn't forwarded, the plugin's conflict warnings never fire here: delete: false + filesToDeleteAfterUpload still deletes, and deleteSourcemapsAfterUpload is silently ignored when delete is set. Should we warn from the SDK, like we do for disable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes. #26626 moves those warnings into @sentry/core, and a follow-up PR calls them from the SDKs that don't forward delete once both land.

timfish added a commit that referenced this pull request Nov 24, 2026
…emselves (#26787)

#26626 added `warnOnConflictingSourceMapOptions`, but only the bundler
plugin calls it, so it only warns about options that reach the plugin.
React Router passes none of the user's source map options to the plugin,
and SvelteKit, Nuxt and Nitro do not pass `sourcemaps.delete`. In these
SDKs, `delete: false` with a user `filesToDeleteAfterUpload` still
deletes the matched files, and nothing warns. These SDKs now call the
warner with the user's options.

Gatsby reads the flat `deleteSourcemapsAfterUpload`, so it logs its own
warning when `sourcemaps.delete` is set next to it.

The warner now logs each message once per process. Each plugin instance
runs it, so Nuxt already printed some warnings twice (from the Vite
plugin and the Nitro plugin), and the new SDK calls would add one more.

Next.js has the same gap. I'll add it to #26337 so the two PRs don't
conflict.

No E2E changes. Unit tests cover the other call sites.
@timfish
timfish merged commit cae3ec7 into develop Nov 24, 2026
481 of 483 checks passed
@timfish
timfish deleted the feat/nextjs-delete-sourcemaps-after-upload branch November 24, 2026 19:26
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.

2 participants