Skip to content

feat(node): Add build-time opt-out for runtime channel injection - #23475

Merged
mydea merged 4 commits into
developfrom
fn/channel-injection-build-flag
Aug 27, 2026
Merged

feat(node): Add build-time opt-out for runtime channel injection#23475
mydea merged 4 commits into
developfrom
fn/channel-injection-build-flag

Conversation

@mydea

@mydeamydea commented Aug 21, 2026

Copy link
Copy Markdown
Member

Stacked on #23473.

Adds a build-time opt-out for the Node SDK's runtime diagnostics-channel injection, complementing the runtime enableRuntimeChannelInjection option from the base PR.

  • New __SENTRY_CHANNEL_INJECTION__ treeshaking flag, mirroring __SENTRY_TRACING__: when a bundler text-replaces it with false, the registerDiagnosticsChannelInjection() / detectOrchestrionSetup() block in init is dropped, and its transitive orchestrion-register code tree-shakes away.
  • Exposed through the bundler plugins' bundleSizeOptimizations.excludeChannelInjection, which maps to __SENTRY_CHANNEL_INJECTION__ = false via the same mechanism as excludeTracing.
  • The gate now reads both the build flag and the runtime option: (typeof __SENTRY_CHANNEL_INJECTION__ === 'undefined' || __SENTRY_CHANNEL_INJECTION__) && options.enableRuntimeChannelInjection !== false.

🤖 Generated with Claude Code

Comment threadpackages/node/test/sdk/diagnosticsChannelInjection.test.ts
@github-actions

github-actionsBot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser28.57 kB--
@sentry/browser - with treeshaking flags26.92 kB--
@sentry/browser - with treeshaking flags tracing without tracing26.82 kB--
@sentry/browser (incl. Tracing)48.59 kB--
@sentry/browser (incl. Tracing + Span Streaming)48.6 kB--
@sentry/browser (incl. Tracing, Profiling)51.51 kB--
@sentry/browser (incl. Tracing, Replay)88.04 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags77.45 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)92.75 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)105.45 kB--
@sentry/browser (incl. Feedback)45.81 kB--
@sentry/browser (incl. sendFeedback)33.36 kB--
@sentry/browser (incl. FeedbackAsync)38.46 kB--
@sentry/browser (incl. Metrics)29.51 kB--
@sentry/browser (incl. Logs)29.8 kB--
@sentry/browser (incl. Metrics & Logs)30.43 kB--
@sentry/react30.31 kB--
@sentry/react (incl. Tracing)50.8 kB--
@sentry/vue35.69 kB--
@sentry/vue (incl. Tracing)50.82 kB--
@sentry/svelte28.59 kB--
CDN Bundle30.36 kB--
CDN Bundle (incl. Tracing)49.06 kB--
CDN Bundle (incl. Logs, Metrics)32.56 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)50.94 kB--
CDN Bundle (incl. Replay, Logs, Metrics)72.98 kB--
CDN Bundle (incl. Tracing, Replay)86.56 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)88.44 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)92.34 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)94.27 kB--
CDN Bundle - uncompressed89.97 kB--
CDN Bundle (incl. Tracing) - uncompressed146.74 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed96.26 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed152.43 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed225.36 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed266.17 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed271.85 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed279.87 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed285.53 kB--
@sentry/nextjs (client)53.34 kB--
@sentry/sveltekit (client)49.02 kB--
@sentry/core/server65.21 kB--
@sentry/core/browser52.34 kB--
@sentry/node121.73 kB+0.04%+37 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection)85.18 kB--
@sentry/node - without tracing87.58 kB+0.06%+51 B 🔺
@sentry/aws-serverless95.98 kB+0.04%+37 B 🔺
@sentry/cloudflare (withSentry) - minified199.48 kB--
@sentry/cloudflare (withSentry)495.44 kB--
@sentry/node - without channel injection101.4 kBaddedadded

View base workflow run

Comment threadpackages/node/src/sdk/index.ts Outdated
@mydea
mydeaforce-pushed the fn/channel-injection-build-flag branch from 1d27eb4 to e670b7cCompareAugust 24, 2026 07:51
@mydea
mydeaforce-pushed the fn/channel-injection-build-flag branch from e670b7c to 40ae0c4CompareAugust 24, 2026 09:04
@mydea
mydea marked this pull request as ready for review August 24, 2026 09:24
@mydea
mydea requested a review from a team as a code ownerAugust 24, 2026 09:24
@mydea
mydea requested review from msonnb and stephanie-anderson and removed request for a teamAugust 24, 2026 09:24
@mydea
mydeaforce-pushed the fn/channel-injection-build-flag branch from 40ae0c4 to 8ff1633CompareAugust 24, 2026 11:06

@cursorcursorBot 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 8ff1633. Configure here.

Comment threadpackages/bundler-plugins/src/core/types.ts
@mydea
mydeaforce-pushed the fn/channel-injection-build-flag branch from 8ff1633 to 5a399f9CompareAugust 24, 2026 11:24
@mydea
mydea requested review from Lms24 and removed request for stephanie-andersonAugust 24, 2026 12:52
@mydea
mydea requested a review from a team as a code ownerAugust 25, 2026 08:12
@mydea
mydea requested review from JPeer264 and isaacs and removed request for a teamAugust 25, 2026 08:12
Base automatically changed from fn/default-framework-integrations to developAugust 25, 2026 12:00
@mydea
mydeaforce-pushed the fn/channel-injection-build-flag branch from 5a399f9 to dac4c3aCompareAugust 25, 2026 13:31

@isaacsisaacs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two small fixes that I think are worth doing before landing, but this looks good otherwise.

*
* @default false
*/
excludeChannelInjection?: boolean;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this also be added to the BundleSizeOptimizationsOptions in packages/core/src/build-time-plugins/buildTimeOptionsBase.ts, so that it can be picked up on the bundleSizeOptimizations field of BuildTimeOptionsBase? Eg, that's what packages/nuxt/src/common/types.ts pulls its options from.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

ah, you are right. this is a bit weird and maybe we can combine these together at some point...

Comment threadpackages/node/src/sdk/index.ts Outdated
Comment threadpackages/node/src/sdk/index.ts Outdated
mydeaand others added 4 commits August 26, 2026 09:35
Introduce a `__SENTRY_CHANNEL_INJECTION__` treeshaking flag (mirroring `__SENTRY_TRACING__`)
that removes the runtime diagnostics-channel injection when text-replaced with `false`, and
expose it through the bundler plugins' `bundleSizeOptimizations.excludeChannelInjection`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: isaacs <i@izs.me>
@mydea
mydeaforce-pushed the fn/channel-injection-build-flag branch from f1c25ae to 00566b9CompareAugust 26, 2026 07:39
@isaacs
isaacs self-requested a review August 26, 2026 14:48

@isaacsisaacs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The blocking concern is addressed, LGTM.

@mydea
mydea merged commit 9c94002 into developAug 27, 2026
273 checks passed
@mydea
mydea deleted the fn/channel-injection-build-flag branch August 27, 2026 06:27
Sign up for freeto 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.

3 participants

@mydea@isaacs@JPeer264