Skip to content

fix(nextjs): Don't turn on source maps when the after-compile hook does not run - #26935

Open
timfish wants to merge 4 commits into
ref/sdk-source-map-glob-optionfrom
fix/nextjs-turbopack-source-maps-without-hook
Open

timfish wants to merge 4 commits into
ref/sdk-source-map-glob-optionfrom
fix/nextjs-turbopack-source-maps-without-hook

Conversation

@timfish

@timfish timfish commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #26906.

With the runAfterProductionCompile hook, only the hook uploads and deletes source maps. The SDK still turned source maps on when the hook was not set up, so they stayed in .next/static, where they are served publicly.

  • Turbopack: the SDK no longer sets productionBrowserSourceMaps: true when useRunAfterProductionCompileHook is false, or when compiler.runAfterProductionCompile is set to something that is not a function.
  • Webpack with useRunAfterProductionCompileHook: true: the SDK no longer changes devtool when the Next.js version is below 15.4.1, or when compiler.runAfterProductionCompile is not a function.
  • sourcemaps.delete: false still turns the maps on, because the user asked to keep them.
  • Source maps that the user turned on are not changed.
  • The two hook call sites now share one function. This keeps the file under the 300-line lint limit.
  • Covered by unit tests only. No E2E app builds with the hook off.

…ternal option

Next.js, Nitro, Nuxt and SvelteKit passed their own globs through the
public `filesToDeleteAfterUpload`. They now pass them through the
internal `sdkFilesToDeleteAfterUpload`. Next.js no longer passes its own
`disable` value or writes `deleteSourcemapsAfterUpload` into the user's
options. SDK messages no longer tell users to set these options.
…pile hook

Only the `runAfterProductionCompile` hook uploads and deletes the source maps of a Turbopack build. Without the hook, the maps that the SDK turned on stayed in `.next/static`.
…hook is not set up

With `useRunAfterProductionCompileHook`, the webpack plugins leave the upload and the deletion to the hook. On a Next.js version without the hook, the source maps that the SDK turned on stayed in `.next/static`.
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 77d062f (PR test merge using ref/sdk-source-map-glob-option at 364ee8c)

Against: 71f41ed (ref/sdk-source-map-glob-option) · base run #68183

⚠️ Baseline mismatch: 1 ref/sdk-source-map-glob-option commit(s) in the PR build are missing from the baseline. Their size changes also affect this comparison. Compare commits. Re-run once ref/sdk-source-map-glob-option's baseline build for 364ee8c finishes.

Path Size % Change Change
@sentry/browser 30.55 kB - -
@sentry/browser - with treeshaking flags 28.74 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.61 kB - -
@sentry/browser (incl. Tracing) 53.68 kB - -
@sentry/browser (incl. Tracing Core) 40.6 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 53.68 kB - -
@sentry/browser (incl. Tracing, Profiling) 56.57 kB - -
@sentry/browser (incl. Tracing, Replay) 93.6 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 82.4 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 98.46 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 111.41 kB - -
@sentry/browser (incl. Feedback) 48.41 kB - -
@sentry/browser (incl. sendFeedback) 31.12 kB - -
@sentry/browser (incl. FeedbackAsync) 36.18 kB - -
@sentry/browser (incl. Metrics) 31.87 kB - -
@sentry/browser (incl. Logs) 32.15 kB - -
@sentry/browser (incl. Metrics & Logs) 32.81 kB - -
@sentry/react 32.58 kB - -
@sentry/react (incl. Tracing) 56.42 kB - -
@sentry/vue 38.76 kB - -
@sentry/vue (incl. Tracing) 56.69 kB - -
@sentry/svelte 30.58 kB - -
@sentry/effect (client) 42.23 kB - -
@sentry/effect (client, incl. Tracing) 54.97 kB - -
@sentry/effect (client, incl. Tracing, Logs, Metrics) 66.32 kB - -
@sentry/remix (Remix 3 client bundle) 59.41 kB - -
CDN Bundle 32.39 kB - -
CDN Bundle (incl. Tracing) 54.05 kB - -
CDN Bundle (incl. Logs, Metrics) 35.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 56.52 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.1 kB - -
CDN Bundle (incl. Tracing, Replay) 91.85 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 94.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.8 kB - -
CDN Bundle - uncompressed 94.58 kB - -
CDN Bundle (incl. Tracing) - uncompressed 159.87 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.92 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 167.49 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 233.32 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 280.3 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 287.93 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.24 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 299.85 kB - -
@sentry/nextjs (client) 60.09 kB - -
@sentry/sveltekit (client) 55.03 kB - -
@sentry/core/server 45.84 kB - -
@sentry/core/browser 14.48 kB - -
@sentry/node 157.4 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.45 kB - -
@sentry/node - without tracing 89.81 kB +0.01% +1 B 🔺
@sentry/node - without channel injection 146.38 kB +0.01% +1 B 🔺
@sentry/aws-serverless 100.44 kB +0.01% +3 B 🔺
@sentry/cloudflare (withSentry) - minified 211.97 kB - -
@sentry/cloudflare (withSentry) 491.78 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 214.92 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 237.22 kB - -

View base workflow run

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

All optional checks were successful. 7 successful. See the run.

Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vinext-cf-workers (workers cache) Test (optional) Successful in 1m Details

@timfish
timfish marked this pull request as ready for review November 26, 2026 15:24
@timfish
timfish force-pushed the ref/sdk-source-map-glob-option branch from d766635 to 364ee8c Compare November 26, 2026 15:25
…into fix/nextjs-turbopack-source-maps-without-hook

# Conflicts:
#	packages/nextjs/src/config/withSentryConfig/getFinalConfigObjectBundlerUtils.ts
#	packages/nextjs/test/config/sourceMapOptions.test.ts
#	packages/nextjs/test/config/webpack/constructWebpackConfig.test.ts
#	packages/nextjs/test/config/withSentryConfig.test.ts

This branch has not been deployed

No deployments
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.

1 participant