Skip to content

fix(nextjs): Stop baking absolute paths into server chunks - #23267

Open
chargome wants to merge 2 commits into
developfrom
fix/nextjs-orchestrion-relocatable-externals
Open

fix(nextjs): Stop baking absolute paths into server chunks#23267
chargome wants to merge 2 commits into
developfrom
fix/nextjs-orchestrion-relocatable-externals

Conversation

@chargome

@chargome chargome commented Aug 11, 2026

Copy link
Copy Markdown
Member

next build with webpack emitted the orchestrion runtime as commonjs <absolute build path> externals, which only resolve on the machine that built them — so any deploy that relocates the output (Vercel, Docker, output: 'standalone') hit MODULE_NOT_FOUND on the first dynamic route. E2E builds and runs in place, hence green CI.

The runtime has to stay external, and a bare @sentry/server-utils doesn't resolve from .next/server/** under isolated installs. It's now reached through @sentry/nextjs, which is always a direct dependency, so the specifier survives the output being moved.

The forwarders are generated from @sentry/server-utils' exports map, so a we do not need to maintain this manually.

closes #23266

`next build` with webpack emitted the orchestrion runtime as
`commonjs <absolute build path>` externals, which only resolve on the
machine that built them — so any deploy that relocates the output
(Vercel, Docker, `output: 'standalone'`) hit `MODULE_NOT_FOUND` on the
first dynamic route.

The runtime has to stay external, and a bare `@sentry/server-utils`
doesn't resolve from `.next/server/**` under isolated installs. It's now
reached through `@sentry/nextjs`, which is always a direct dependency, so
the specifier survives the output being moved.

Fixes #23266

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chargome chargome self-assigned this Aug 11, 2026
@chargome

chargome commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

buglitzer kum

Comment thread dev-packages/test-utils/src/build-output.ts Fixed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 757ba04. Configure here.

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 30.26 kB - -
@sentry/browser - with treeshaking flags 28.44 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.78 kB - -
@sentry/browser (incl. Tracing) 48.5 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.52 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.4 kB - -
@sentry/browser (incl. Tracing, Replay) 87.94 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.3 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.65 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.32 kB - -
@sentry/browser (incl. Feedback) 47.58 kB - -
@sentry/browser (incl. sendFeedback) 35.08 kB - -
@sentry/browser (incl. FeedbackAsync) 40.23 kB - -
@sentry/browser (incl. Metrics) 31.29 kB - -
@sentry/browser (incl. Logs) 31.55 kB - -
@sentry/browser (incl. Metrics & Logs) 32.24 kB - -
@sentry/react 32.06 kB - -
@sentry/react (incl. Tracing) 50.69 kB - -
@sentry/vue 35.32 kB - -
@sentry/vue (incl. Tracing) 50.45 kB - -
@sentry/svelte 30.28 kB - -
CDN Bundle 31.52 kB - -
CDN Bundle (incl. Tracing) 48.78 kB - -
CDN Bundle (incl. Logs, Metrics) 33.75 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.76 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.3 kB - -
CDN Bundle (incl. Tracing, Replay) 86.38 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.29 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.08 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.1 kB - -
CDN Bundle - uncompressed 93.59 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.5 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.06 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.36 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 228.98 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.75 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.6 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.45 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.28 kB - -
@sentry/nextjs (client) 53.24 kB - -
@sentry/sveltekit (client) 48.91 kB - -
@sentry/core/server 65.45 kB - -
@sentry/core/browser 51.79 kB - -
@sentry/node 117.89 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 82.05 kB -0.01% -1 B 🔽
@sentry/aws-serverless 91.42 kB - -
@sentry/cloudflare (withSentry) - minified 214.07 kB - -
@sentry/cloudflare (withSentry) 528.94 kB - -

View base workflow run

`build/orchestrion-runtime` was not in the `build:transpile` Nx outputs,
so it was neither cached nor uploaded as a CI build artifact — leaving
the unit-test job and every packed tarball without it. Same override
`@sentry/node` already uses for its `import-hook.mjs`, which was missing
here too.

Also read directory entries with `withFileTypes` instead of a separate
`statSync` before each read, which drops a syscall per entry and the
CodeQL file-system-race warning it raised.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment on lines +118 to +131
"nx": {
"targets": {
"build:transpile": {
"outputs": [
"{projectRoot}/build/esm",
"{projectRoot}/build/cjs",
"{projectRoot}/build/npm/esm",
"{projectRoot}/build/npm/cjs",
"{projectRoot}/build/import-hook.mjs",
"{projectRoot}/build/orchestrion-runtime"
]
}
}
},

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.

Nx and CI only keep the build files a package explicitly declares, so this was needed for tarballs, artifacts etc

@chargome
chargome marked this pull request as ready for review August 11, 2026 12:13
@chargome
chargome requested review from a team as code owners August 11, 2026 12:13
@chargome
chargome requested review from JPeer264, andreiborza, mydea, s1gr1d and timfish and removed request for a team, mydea and s1gr1d August 11, 2026 12:13
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.

Next.js webpack builds bake absolute paths into server chunks, breaking relocated deploys

3 participants