Skip to content

ref(server-utils): Unify orchestrion injection into a single tracingChannelImport transform - #23075

Open
timfish wants to merge 4 commits into
developfrom
timfish/chore/streamline-orchestrion-injection
Open

ref(server-utils): Unify orchestrion injection into a single tracingChannelImport transform#23075
timfish wants to merge 4 commits into
developfrom
timfish/chore/streamline-orchestrion-injection

Conversation

@timfish

@timfish timfish commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Consolidates the five overlapping orchestrion injection mechanisms (subscribe-injection
transform, injectDiagnostics module-list banner, Turbopack loader append, onInject
bridge, per-path marker writes) into one always-on tracingChannelImport override that
splices a single snippet into every instrumented module.

Why:

  • Five mechanisms wrote the same global with different semantics — the banner assigned
    g.bundler (clobbering earlier pushes), Bun set bundler = true (special-cased in
    three places).
  • The bundler banner announced all transformed modules eagerly at boot, defeating the lazy
    subscription design (Node's 1024-channel cap). Now they're only subscribed of they're actually loaded.
  • customTransforms never survived webpack/Turbopack's serialized loader options, so
    injectChannelSubscribers silently never worked there.

How:

  • Injected snippet calls orchestrionModuleInjected("<module>", <factory?>) when the
    module is evaluated: records it on the marker, stores its subscriber factory (keyed by
    real state.module.name — no more reverse lookup or path-splitting heuristic), emits
    the client event. Record + emit only — no addIntegration; Cloudflare listens for the
    event instead to install factories registered after per-request init().
  • Banner reduced to a merge-only "plugin ran" marker: g.bundler = g.bundler || [].
  • Client event renamed orchestrion.module-runtime-injectedorchestrion.module-injected.
  • Loader rebuilt on upstream 0.7.4 createLoader — transforms are baked into our loader
    module, so only JSON crosses the Turbopack boundary; webpack plugin configures upstream
    via loaderPath/cacheVersion instead of patching its rule.
  • Snippet import resolution under isolated installs (pnpm): resolveId/onResolve/alias
    fallbacks per bundler; Turbopack gets an absolute-path importSpecifier loader option.
  • Bun folded in: array banner + baked-in transform.
  • Fixes the coverage gap for instrumented modules without a subscriber factory (knex,
    mongodb, …) — they now announce on the marker/event too.

Removed:

  • injectChannelSubscribers (+ 4 framework call sites), dead shouldInjectDiagnostics,
    the module-list banner, the Turbopack append snippet, marker.onInject + init-time
    bridge, registerOrchestrionChannelIntegration, the bundler: true special cases.

Deps: @apm-js-collab/code-transformer-bundler-plugins ^0.7.3^0.7.4 (adds the
loader factory and webpack customTransforms forwarding this builds on).

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.12 kB - -
@sentry/browser - with treeshaking flags 28.32 kB - -
@sentry/browser (incl. Tracing) 47.53 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.54 kB - -
@sentry/browser (incl. Tracing, Profiling) 52.29 kB - -
@sentry/browser (incl. Tracing, Replay) 86.91 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 76.33 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 91.6 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 104.25 kB - -
@sentry/browser (incl. Feedback) 47.45 kB - -
@sentry/browser (incl. sendFeedback) 34.96 kB - -
@sentry/browser (incl. FeedbackAsync) 40.1 kB - -
@sentry/browser (incl. Metrics) 31.2 kB - -
@sentry/browser (incl. Logs) 31.41 kB - -
@sentry/browser (incl. Metrics & Logs) 32.11 kB - -
@sentry/react 31.93 kB - -
@sentry/react (incl. Tracing) 49.79 kB - -
@sentry/vue 35.2 kB - -
@sentry/vue (incl. Tracing) 49.51 kB - -
@sentry/svelte 30.14 kB - -
CDN Bundle 32.13 kB - -
CDN Bundle (incl. Tracing) 47.81 kB - -
CDN Bundle (incl. Logs, Metrics) 33.67 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.19 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.02 kB - -
CDN Bundle (incl. Tracing, Replay) 85.45 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.27 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.59 kB - -
CDN Bundle - uncompressed 95.27 kB - -
CDN Bundle (incl. Tracing) - uncompressed 142.78 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.9 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 146.75 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224.6 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.03 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 275.74 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 279.69 kB - -
@sentry/nextjs (client) 52.36 kB - -
@sentry/sveltekit (client) 47.99 kB - -
@sentry/core/server 65.54 kB - -
@sentry/core/browser 51.82 kB - -
@sentry/node 120.42 kB -0.04% -38 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 84.08 kB -0.05% -34 B 🔽
@sentry/aws-serverless 92.57 kB -0.05% -42 B 🔽
@sentry/cloudflare (withSentry) - minified 217.94 kB +0.06% +127 B 🔺
@sentry/cloudflare (withSentry) 537.3 kB +0.05% +243 B 🔺

View base workflow run

@timfish
timfish marked this pull request as ready for review August 6, 2026 06:46
@timfish
timfish requested review from a team as code owners August 6, 2026 06:46
@timfish
timfish requested review from JPeer264, isaacs, mydea, nicohrubec and s1gr1d and removed request for a team August 6, 2026 06:46
cursor[bot]

This comment was marked as outdated.

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