Skip to content

fix(server-utils): Keep orchestrion registration out of tree-shaking - #23590

Merged
andreiborza merged 1 commit into
developfrom
ab/fix-orchestrion-snippet-treeshake
Aug 25, 2026
Merged

fix(server-utils): Keep orchestrion registration out of tree-shaking#23590
andreiborza merged 1 commit into
developfrom
ab/fix-orchestrion-snippet-treeshake

Conversation

@andreiborza

Copy link
Copy Markdown
Member

What

Keep the orchestrion registration that the bundler transform injects from being tree-shaken away.

  • Assign the injected orchestrionModuleInjected(...) result to a globalThis property instead of discarding it.

Why

The helper returns void and @sentry/server-utils sets sideEffects: false, so a bare call statement is one a bundler can prove droppable. rollup 4.63.0 (released 2026-08-25) does, and drops the registration. Instrumented modules then publish on their diagnostics channel with nothing subscribed, so no spans are recorded. This currently breaks every Cloudflare E2E app that instruments through the vite transform, and it silently disables DB instrumentation for users on vite or rollup 4.63.0 and later.

The bundler transform injected a bare `orchestrionModuleInjected(...)` call.
The helper returns `void` and `@sentry/server-utils` sets `sideEffects: false`,
so bundlers may prove the statement droppable. rollup 4.63.0 does, and removes
the registration: instrumented modules publish on their channel, but nothing
subscribes, so no spans are recorded.

Assign the result to a `globalThis` property. A write to a global is a side
effect no bundler can shake out, so the call survives while the rest of the
package still tree-shakes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@andreiborza
andreiborza marked this pull request as ready for review August 25, 2026 14:31
@andreiborza
andreiborza requested a review from a team as a code owner August 25, 2026 14:31
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.5 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.52 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.43 kB - -
@sentry/browser (incl. Tracing, Replay) 87.89 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.35 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.59 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.3 kB - -
@sentry/browser (incl. Feedback) 45.81 kB - -
@sentry/browser (incl. sendFeedback) 33.36 kB - -
@sentry/browser (incl. FeedbackAsync) 38.47 kB - -
@sentry/browser (incl. Metrics) 29.52 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.45 kB - -
@sentry/react 30.33 kB - -
@sentry/react (incl. Tracing) 50.71 kB - -
@sentry/vue 35.64 kB - -
@sentry/vue (incl. Tracing) 50.73 kB - -
@sentry/svelte 28.6 kB - -
CDN Bundle 30.32 kB - -
CDN Bundle (incl. Tracing) 49.02 kB - -
CDN Bundle (incl. Logs, Metrics) 32.54 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.89 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.91 kB - -
CDN Bundle (incl. Tracing, Replay) 86.47 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.22 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.17 kB - -
CDN Bundle - uncompressed 89.94 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.64 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.23 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.33 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.18 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.92 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.6 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.62 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.28 kB - -
@sentry/nextjs (client) 53.23 kB - -
@sentry/sveltekit (client) 48.92 kB - -
@sentry/core/server 65.11 kB - -
@sentry/core/browser 52.27 kB - -
@sentry/node 121.58 kB +0.02% +20 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 87.46 kB +0.03% +24 B 🔺
@sentry/aws-serverless 95.86 kB +0.03% +25 B 🔺
@sentry/cloudflare (withSentry) - minified 199.28 kB - -
@sentry/cloudflare (withSentry) 495.43 kB - -

View base workflow run

@andreiborza
andreiborza merged commit 936541e into develop Aug 25, 2026
202 checks passed
@andreiborza
andreiborza deleted the ab/fix-orchestrion-snippet-treeshake branch August 25, 2026 14:44
andreiborza added a commit that referenced this pull request Aug 26, 2026
…ing (#23591)

Backport of: #23590

## Differences to the original PR

- Applied to
`packages/server-utils/src/orchestrion/bundler/subscribeInjection.ts`
instead of `moduleInjectedTransform.ts`. v10 predates that refactor, so
the injected snippet calls `registerOrchestrionChannelIntegration`
rather than `orchestrionModuleInjected`. The defect is the same: that
helper also returns `void`, and v10's `@sentry/server-utils` also sets
`sideEffects: false`.
- Test updated in `test/orchestrion/subscribeInjection.test.ts` rather
than `test/orchestrion/moduleInjectedTransform.test.ts`, for the same
reason.
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