Skip to content

fix(nextjs): Inject build values into instrumentation for an external server SDK - #26292

Merged
JPeer264 merged 1 commit into
developfrom
jp/nextjs-external-sdk-build-values
Nov 13, 2026
Merged

JPeer264 merged 1 commit into
developfrom
jp/nextjs-external-sdk-build-values

Conversation

@JPeer264

Copy link
Copy Markdown
Member

part of #24830
part of JS-3835

On Turbopack builds, this injects the build release, the dist dir, the base path and a Turbopack flag as globals into instrumentation.*. Webpack builds already inject most of them.

Why

Next.js inlines nextConfig.env and process.turbopack only into code it compiles. When @sentry/nextjs is in serverExternalPackages, the server SDK had no build release, did not rewrite stack frames of the dist dir and did not set the turbopack tag.

@linear-code

linear-code Bot commented Nov 11, 2026

Copy link
Copy Markdown

JS-3835

@JPeer264
JPeer264 added this pull request to stack #26296 November 11, 2026 13:56
@JPeer264
JPeer264 marked this pull request as ready for review November 11, 2026 14:14
@JPeer264
JPeer264 requested review from a team, msonnb and stephanie-anderson November 11, 2026 14:14
@JPeer264
JPeer264 requested a review from a team as a code owner November 11, 2026 14:14
@JPeer264 JPeer264 self-assigned this Nov 11, 2026
@JPeer264
JPeer264 requested review from chargome and isaacs and removed request for msonnb and stephanie-anderson November 11, 2026 14:15
@JPeer264
JPeer264 force-pushed the jp/nextjs-external-sdk-build-values branch from f9736f6 to b891775 Compare November 11, 2026 15:09
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: d5837c3 (PR test merge using develop at 621a801)

Against: 621a801 (develop) · base run #65856

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

Path Size % Change Change
@sentry/browser 30.04 kB - -
@sentry/browser - with treeshaking flags 28.23 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.12 kB - -
@sentry/browser (incl. Tracing) 52.2 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.2 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.17 kB - -
@sentry/browser (incl. Tracing, Replay) 92.73 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.52 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.08 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.51 kB - -
@sentry/browser (incl. Feedback) 47.66 kB - -
@sentry/browser (incl. sendFeedback) 30.62 kB - -
@sentry/browser (incl. FeedbackAsync) 35.62 kB - -
@sentry/browser (incl. Metrics) 31.36 kB - -
@sentry/browser (incl. Logs) 31.64 kB - -
@sentry/browser (incl. Metrics & Logs) 32.3 kB - -
@sentry/react 32.04 kB - -
@sentry/react (incl. Tracing) 54.86 kB - -
@sentry/vue 38.21 kB - -
@sentry/vue (incl. Tracing) 55.14 kB - -
@sentry/svelte 30.05 kB - -
@sentry/remix (Remix 3 client bundle) 57.96 kB - -
CDN Bundle 31.79 kB - -
CDN Bundle (incl. Tracing) 52.58 kB - -
CDN Bundle (incl. Logs, Metrics) 34.58 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.14 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.61 kB - -
CDN Bundle (incl. Tracing, Replay) 90.63 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.25 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.6 kB - -
CDN Bundle - uncompressed 92.69 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.13 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.03 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 162.76 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 231.11 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 275.27 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 282.9 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.07 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 294.69 kB - -
@sentry/nextjs (client) 58.23 kB - -
@sentry/sveltekit (client) 53.26 kB - -
@sentry/core/server 44.53 kB - -
@sentry/core/browser 13.99 kB - -
@sentry/node 149.48 kB -0.01% -4 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.3 kB - -
@sentry/node - without tracing 88.38 kB -0.01% -5 B 🔽
@sentry/node - without channel injection 138.45 kB -0.01% -3 B 🔽
@sentry/aws-serverless 97.29 kB -0.01% -7 B 🔽
@sentry/cloudflare (withSentry) - minified 204.35 kB - -
@sentry/cloudflare (withSentry) 474.32 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 229.66 kB - -

View base workflow run

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 1 not successful, 10 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E nextjs-16-cacheComponents (cloudflare) Test (optional) Failing after 10m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) 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 supabase-nextjs Test (optional) Successful in 2m Details

vercelCronsConfig,
releaseName,
// Same value as `_sentryRewriteFramesDistDir` in `nextConfig.env`
distDirName: userNextConfig.distDir?.replace(/\\/g, '\\\\') || '.next',

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.

as discussed offline, this might not work on windows.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just checked, this is also in there since 2 years for webpack, and worked so far. So I'd rather want to keep it

@isaacs
isaacs removed this pull request from stack #26296 November 12, 2026 10:24
@isaacs
isaacs force-pushed the jp/nextjs-external-sdk-build-values branch from b891775 to 551eae7 Compare November 12, 2026 10:25
@isaacs
isaacs added this pull request to stack #26315 November 12, 2026 10:28
@isaacs
isaacs force-pushed the jp/nextjs-external-sdk-build-values branch from 551eae7 to b21bc14 Compare November 12, 2026 11:19
@JPeer264
JPeer264 requested a review from s1gr1d November 12, 2026 12:41
… server SDK

Next.js inlines the values of `nextConfig.env` and `process.turbopack` only
into code it compiles. When `@sentry/nextjs` is in `serverExternalPackages`,
Turbopack builds therefore lost the build release, the dist dir for the stack
frame rewrite, the base path and the `turbopack` tag. Turbopack now also
injects these values as globals into `instrumentation.*`, as webpack already
does for most of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/nextjs-external-sdk-build-values branch from b21bc14 to 4818c22 Compare November 12, 2026 13:28
@JPeer264
JPeer264 merged commit 7b18bf0 into develop Nov 13, 2026
110 of 111 checks passed
@JPeer264
JPeer264 deleted the jp/nextjs-external-sdk-build-values branch November 13, 2026 06:40
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