Skip to content

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

Open
mydea wants to merge 1 commit into
fn/default-framework-integrationsfrom
fn/channel-injection-build-flag
Open

feat(node): Add build-time opt-out for runtime channel injection#23475
mydea wants to merge 1 commit into
fn/default-framework-integrationsfrom
fn/channel-injection-build-flag

Conversation

@mydea

@mydea mydea 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 thread packages/node/test/sdk/diagnosticsChannelInjection.test.ts
@github-actions

github-actions Bot commented Aug 21, 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 30.3 kB - -
@sentry/browser - with treeshaking flags 28.47 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.81 kB - -
@sentry/browser (incl. Tracing) 48.62 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.64 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.51 kB - -
@sentry/browser (incl. Tracing, Replay) 88.02 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.42 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.74 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.45 kB - -
@sentry/browser (incl. Feedback) 47.65 kB - -
@sentry/browser (incl. sendFeedback) 35.13 kB - -
@sentry/browser (incl. FeedbackAsync) 40.28 kB - -
@sentry/browser (incl. Metrics) 31.24 kB - -
@sentry/browser (incl. Logs) 31.52 kB - -
@sentry/browser (incl. Metrics & Logs) 32.15 kB - -
@sentry/react 32.09 kB - -
@sentry/react (incl. Tracing) 50.81 kB - -
@sentry/vue 35.34 kB - -
@sentry/vue (incl. Tracing) 50.61 kB - -
@sentry/svelte 30.33 kB - -
CDN Bundle 31.61 kB - -
CDN Bundle (incl. Tracing) 48.96 kB - -
CDN Bundle (incl. Logs, Metrics) 33.8 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.87 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.31 kB - -
CDN Bundle (incl. Tracing, Replay) 86.53 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.37 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.24 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.18 kB - -
CDN Bundle - uncompressed 93.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.82 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.08 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.08 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.76 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.78 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.45 kB - -
@sentry/nextjs (client) 53.36 kB - -
@sentry/sveltekit (client) 49.04 kB - -
@sentry/core/server 65.56 kB - -
@sentry/core/browser 51.78 kB - -
@sentry/node 117.49 kB +0.04% +44 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 87.49 kB +6.71% +5.5 kB 🔺
@sentry/aws-serverless 95.84 kB +4.84% +4.42 kB 🔺
@sentry/cloudflare (withSentry) - minified 194.61 kB - -
@sentry/cloudflare (withSentry) 481.16 kB - -

View base workflow run

Comment thread packages/node/src/sdk/index.ts
@mydea
mydea force-pushed the fn/channel-injection-build-flag branch from 1d27eb4 to e670b7c Compare August 24, 2026 07:51
@mydea
mydea force-pushed the fn/channel-injection-build-flag branch from e670b7c to 40ae0c4 Compare August 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 owner August 24, 2026 09:24
@mydea
mydea requested review from msonnb and stephanie-anderson and removed request for a team August 24, 2026 09:24
@mydea
mydea force-pushed the fn/channel-injection-build-flag branch from 40ae0c4 to 8ff1633 Compare August 24, 2026 11:06

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

Comment thread packages/bundler-plugins/src/core/types.ts
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>
@mydea
mydea force-pushed the fn/channel-injection-build-flag branch from 8ff1633 to 5a399f9 Compare August 24, 2026 11:24
@mydea
mydea requested review from Lms24 and removed request for stephanie-anderson August 24, 2026 12:52
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