Skip to content

fix(server-runtime-injection): Resolve the orchestrion ESM hook by path so build tracers follow it - #23687

Merged
andreiborza merged 2 commits into
ab/e2e-nextjs-16-standalonefrom
ab/fix-standalone-orchestrion-hook-tracing
Sep 2, 2026
Merged

andreiborza merged 2 commits into
ab/e2e-nextjs-16-standalonefrom
ab/fix-standalone-orchestrion-hook-tracing

Conversation

@andreiborza

@andreiborza andreiborza commented Aug 27, 2026

Copy link
Copy Markdown
Member

Stacked on #23679.

What

register.ts (now in @sentry/server-runtime-injection) resolves the orchestrion ESM loader hook from its own on-disk location instead of through the @sentry/server-runtime-injection/hook self-reference, and the standalone e2e app asserts the hook reaches the traced output. It keeps the self-reference as a fallback for a bundled copy, where the relative path points at nothing.

Fixes JS-3451.

Why

Module.register() resolves its specifier at runtime. @vercel/nft does evaluate those calls, but not through the interop namespace helper rollup emits in the CJS build, which is the build Next.js loads, so the hook never reached traced output. output: 'standalone', Docker and Vercel deploys then lost channel-based instrumentation entirely, and only said so behind debug: true. The new path is a literal that both builds expose to tracers, computed at runtime so nothing absolute is baked in.

@linear-code

linear-code Bot commented Aug 27, 2026

Copy link
Copy Markdown

JS-3451

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.94 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.83 kB - -
@sentry/browser (incl. Tracing) 48.87 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.88 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.8 kB - -
@sentry/browser (incl. Tracing, Replay) 88.36 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.76 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.05 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106.02 kB - -
@sentry/browser (incl. Feedback) 46.06 kB - -
@sentry/browser (incl. sendFeedback) 33.64 kB - -
@sentry/browser (incl. FeedbackAsync) 38.74 kB - -
@sentry/browser (incl. Metrics) 29.52 kB - -
@sentry/browser (incl. Logs) 29.81 kB - -
@sentry/browser (incl. Metrics & Logs) 30.45 kB - -
@sentry/react 30.32 kB - -
@sentry/react (incl. Tracing) 51.08 kB - -
@sentry/vue 35.74 kB - -
@sentry/vue (incl. Tracing) 51.14 kB - -
@sentry/svelte 28.6 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.52 kB - -
CDN Bundle (incl. Logs, Metrics) 32.59 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.19 kB - -
CDN Bundle (incl. Tracing, Replay) 87.01 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.88 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.94 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.84 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 147.58 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.27 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.27 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.43 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.75 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.44 kB - -
@sentry/nextjs (client) 53.7 kB - -
@sentry/sveltekit (client) 49.3 kB - -
@sentry/core/server 40.74 kB - -
@sentry/core/browser 13.42 kB - -
@sentry/node 123.99 kB +0.08% +93 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.51 kB +0.15% +114 B 🔺
@sentry/node - without tracing 88.3 kB +0.14% +120 B 🔺
@sentry/node - without channel injection 103.3 kB -0.04% -33 B 🔽
@sentry/aws-serverless 96.66 kB +0.14% +126 B 🔺
@sentry/cloudflare (withSentry) - minified 201.23 kB - -
@sentry/cloudflare (withSentry) 500.94 kB - -

View base workflow run

@mydea

mydea commented Aug 27, 2026

Copy link
Copy Markdown
Member

not sure but this could conflict/overlap with #23685?

@andreiborza

andreiborza commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

@mydea yea, I'll wait until yours lands.

@andreiborza
andreiborza force-pushed the ab/fix-standalone-orchestrion-hook-tracing branch from badd3e7 to 09caa8b Compare September 1, 2026 11:42
@andreiborza andreiborza changed the title fix(server-utils): Resolve the orchestrion ESM hook by path so build tracers follow it fix(server-runtime-injection): Resolve the orchestrion ESM hook by path so build tracers follow it Sep 1, 2026
@andreiborza
andreiborza force-pushed the ab/fix-standalone-orchestrion-hook-tracing branch from 09caa8b to e4cd548 Compare September 1, 2026 11:50
@andreiborza
andreiborza force-pushed the ab/fix-standalone-orchestrion-hook-tracing branch from e4cd548 to 8bfd325 Compare September 1, 2026 12:28
…th so build tracers follow it

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@andreiborza
andreiborza force-pushed the ab/fix-standalone-orchestrion-hook-tracing branch from 8bfd325 to f91a830 Compare September 1, 2026 12:33

@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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f91a830. Configure here.

Comment thread packages/server-runtime-injection/src/register.ts
@andreiborza
andreiborza marked this pull request as ready for review September 1, 2026 13:01
@andreiborza
andreiborza requested review from a team as code owners September 1, 2026 13:01
@andreiborza
andreiborza requested review from a team, chargome, mydea, nicohrubec and s1gr1d and removed request for a team and nicohrubec September 1, 2026 13:01
@mydea

mydea commented Sep 2, 2026

Copy link
Copy Markdown
Member

Seems fine to me! Maybe a test actually running nft would be nice?

@andreiborza

Copy link
Copy Markdown
Member Author

Added `test/nftTrace.test.ts`, which runs @vercel/nft over both built entry points and asserts build/esm/hook.js, its package.json type marker and the vendored chunks land in the trace. Control run on the bare specifier: the CJS case fails, and the ESM case passes, which turned out to be the real shape of the bug: nft does evaluate Module.register(), but not through the interop namespace helper rollup emits in our CJS build, which is the build Next.js loads. Comment and PR body corrected to say that.

@andreiborza
andreiborza merged commit 72a0235 into develop Sep 2, 2026
290 checks passed
@andreiborza
andreiborza deleted the ab/fix-standalone-orchestrion-hook-tracing branch September 2, 2026 09:10
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