Skip to content

feat(server-runtime-injection): Split runtime orchestrion injection into a dedicated package - #23685

Open
mydea wants to merge 4 commits into
fix/orchestrion-detect-bundlingfrom
split/server-runtime-injection
Open

feat(server-runtime-injection): Split runtime orchestrion injection into a dedicated package#23685
mydea wants to merge 4 commits into
fix/orchestrion-detect-bundlingfrom
split/server-runtime-injection

Conversation

@mydea

@mydea mydea commented Aug 27, 2026

Copy link
Copy Markdown
Member

Stacked on #23675 (the detect/warn work) — base this on fix/orchestrion-detect-bundling; rebase onto develop once #23675 merges.

The runtime diagnostics-channel injection (register/hook/import-hook + the vendored transformer chain meriyah/esquery/astring/source-map/tracing-hooks) must stay external when apps bundle their server, while the rest of @sentry/server-utils (barrel + config + bundler plugins) is meant to be bundled. Sharing one package made externalization fiddly (Next.js forwarders, the vite plugin couldn't cleanly separate them). This moves the runtime injection into a new package, @sentry/server-runtime-injection, so "keep this external" is a clean package boundary.

What moves / stays

  • New @sentry/server-runtime-injection: register/hook/import-hook (clean subpaths /register, /hook, /import-hook) + the vendored transformer chain. It depends on @sentry/server-utils and imports SENTRY_INSTRUMENTATIONS from ./orchestrion/configconfig stays put (pure data; resolves from node_modules, one-way dep, no cycle), so @sentry/server-utils remains fully bundleable.
  • @sentry/server-utils: drops the runtime dir/exports and the runtime-only vendored dep (@apm-js-collab/tracing-hooks); keeps the barrel + config + bundler plugins.
  • Bun plugin moved into @sentry/server-utils as ./orchestrion/bun, alongside the vite/rollup/webpack/esbuild plugins; @sentry/bun/plugin now just re-exports it as sentryBunPlugin. This lets config/index.ts drop its bundler re-export (it only existed so @sentry/bun could compose the upstream plugin itself), keeping ./orchestrion/config transformer-free without needing a separate bundler-transforms subpath.

References updated

  • Node SDK (sdk/index.ts + test mock), Deno (import.mjs), the shared --import template + makeOrchestrionLoader guard (one source for every framework's generated hook).
  • Next.js: ORCHESTRION_RUNTIME_EXTERNAL_PACKAGES → the new package; the require-ability check is re-anchored at @sentry/nextjs (so it works under pnpm, where a server-utils-anchored resolver couldn't see the new package); forwarder generation iterates the new package's exports; tests updated.
  • .size-limit.js hook path; the @sentry/server-runtime-injection dep added to node/nextjs/deno/aws-serverless/google-cloud-serverless/astro/tanstackstart-react.
  • Registration: root workspaces, .craft.yml (base tier, after server-utils), CODEOWNERS, the aws-serverless e2e packagesToLink.

Verification

New package builds (config external, transformer vendored, own THIRD-PARTY-LICENSES) and its tests pass; server-utils (353), node (362), bun (50), and the Next.js config tests (122) pass; lint clean across all changed packages. Smoke-tested register in ESM + CJS (healthy → hooks install, no warning), the relocated bun plugin (banner + force-bundle instrumented deps), and confirmed the detection probe still fires on a tree-shaken bundle (warns once, exit 0). size-limit unchanged@sentry/node 119.79 kB, hook entry 79.78 kB, all pass.

Follow-ups

🤖 Generated with Claude Code

Comment thread dev-packages/rollup-utils/npmHelpers.mjs
Comment thread packages/bun/src/plugin.ts
@github-actions

github-actions Bot commented Aug 27, 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 28.56 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.63 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.64 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.55 kB - -
@sentry/browser (incl. Tracing, Replay) 88.09 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.52 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.79 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.74 kB - -
@sentry/browser (incl. Feedback) 46.05 kB - -
@sentry/browser (incl. sendFeedback) 33.63 kB - -
@sentry/browser (incl. FeedbackAsync) 38.73 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.3 kB - -
@sentry/react (incl. Tracing) 50.83 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.86 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.35 kB - -
CDN Bundle (incl. Tracing) 49.24 kB - -
CDN Bundle (incl. Logs, Metrics) 32.57 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.12 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.17 kB - -
CDN Bundle (incl. Tracing, Replay) 86.72 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.62 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.51 kB - -
CDN Bundle - uncompressed 89.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.82 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.24 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.41 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.02 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.69 kB - -
@sentry/nextjs (client) 53.41 kB - -
@sentry/sveltekit (client) 49.07 kB - -
@sentry/core/server 65.15 kB - -
@sentry/core/browser 51.88 kB - -
@sentry/node 123.07 kB +0.29% +350 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.71 kB -4.14% -3.52 kB 🔽
@sentry/node - without tracing 88.14 kB +0.49% +427 B 🔺
@sentry/node - without channel injection 102.4 kB +0.02% +16 B 🔺
@sentry/aws-serverless 96.34 kB +0.49% +461 B 🔺
@sentry/cloudflare (withSentry) - minified 199.69 kB - -
@sentry/cloudflare (withSentry) 496.19 kB - -

View base workflow run

@mydea
mydea marked this pull request as ready for review August 27, 2026 14:28
@mydea
mydea requested review from a team as code owners August 27, 2026 14:28
@mydea
mydea requested review from JPeer264, chargome, isaacs and s1gr1d and removed request for a team August 27, 2026 14:28
@mydea
mydea force-pushed the split/server-runtime-injection branch from c734727 to 24c382c Compare August 28, 2026 09:27
mydea and others added 4 commits August 28, 2026 11:50
…nto a dedicated package

The runtime diagnostics-channel injection (`register`/`hook`/`import-hook` + the
vendored transformer chain meriyah/esquery/astring/source-map/tracing-hooks) must
stay EXTERNAL when apps bundle their server, while the rest of `@sentry/server-utils`
(barrel + config + bundler plugins) is meant to be bundled. Sharing one package made
externalization fiddly. This moves the runtime injection into a new package,
`@sentry/server-runtime-injection`, so "keep this external" is a clean package boundary.

- New package holds `register`/`hook`/`import-hook` (subpaths `/register`, `/hook`,
  `/import-hook`) and vendors the transformer chain; it depends on `@sentry/server-utils`
  and imports `SENTRY_INSTRUMENTATIONS` from `./orchestrion/config` (config stays put).
- `@sentry/server-utils` drops the runtime dir/exports and the runtime-only vendored deps;
  the lone `config/index.ts` bundler re-export moves to a new `./orchestrion/bundler-transforms`
  subpath so importing config stays transformer-free (bun updated).
- References updated: node SDK + test mock, deno import, the shared `--import` template +
  `makeOrchestrionLoader` guard, Next.js externalization (`ORCHESTRION_RUNTIME_EXTERNAL_PACKAGES`,
  nextjs-anchored require-ability check, forwarder generation) + tests, `.size-limit.js`.
- Dep added to runtime-injection consumers (node, nextjs, deno, aws/gcp-serverless, astro,
  tanstackstart-react); package registered in workspaces, `.craft.yml`, CODEOWNERS, aws e2e.

Stacked on the detect/warn PR (#23675).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-plugins dependency

`@sentry/bun/plugin` now only re-exports from `@sentry/server-utils/orchestrion/bun`
(which vendors the transformer), so the direct import is gone. Remove the leftover
runtime dependency so installs don't pull an unused package.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea
mydea force-pushed the split/server-runtime-injection branch from 24c382c to 2a2a5e3 Compare August 28, 2026 09:50

@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 2a2a5e3. Configure here.

}
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Feat PR lacks integration coverage

Low Severity

This is a feat PR that introduces @sentry/server-runtime-injection as a new package boundary, but it has no new integration or E2E test for the split. Existing unit tests and the aws-serverless packagesToLink update do not cover a bundled server keeping the new package external. Flagged because the review rules require a feat PR to include at least one integration or E2E test.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 2a2a5e3. Configure here.

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