feat(node): Auto-exclude runtime channel injection when build-time instrumentation is on - #23479
Draft
mydea wants to merge 7 commits into
Draft
Conversation
Contributor
size-limit report 📦
|
mydea
force-pushed
the
fn/bundler-auto-exclude-channel-injection
branch
from
August 21, 2026 11:02
54b29f6 to
f119671
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c00ea78. Configure here.
mydea
force-pushed
the
fn/bundler-auto-exclude-channel-injection
branch
from
August 24, 2026 07:51
8a9b5ff to
2e080ad
Compare
…tation is enabled The `@sentry/node` bundler plugins inject the orchestrion diagnostics channels at build time. When that is on (the default), the SDK's runtime channel injection is redundant, so default `bundleSizeOptimizations.excludeChannelInjection` to `true` to tree-shake the runtime hooks out. Users can still override it explicitly, and the default is skipped when `buildTimeInstrumentation: false`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… plugin excludes runtime injection Build the entry twice: plain webpack (runtime channel injection bundled by default) and with `sentryWebpackPlugin` (build-time instrumentation), which defaults `excludeChannelInjection` to true and tree-shakes the runtime injection out. assert.mjs verifies the marker is present in the plain build and absent in the plugin build. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ng runs The dead `if (useChannelInjection)` branch is only pruned by the minifier, so `minimize: false` left the runtime injection in the bundle. Verified: with `minimize: true`, the real `sentryWebpackPlugin` excludes the runtime injection while a plain build keeps it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tests Mirror node-webpack for Vite and Rollup: build the entry plain and with the respective Sentry plugin, and assert the runtime channel-injection marker is present in the plain build but tree-shaken out with the plugin (build-time instrumentation defaults `excludeChannelInjection` to true). Verified locally that both bundlers tree-shake the runtime injection. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Build the entry plain and with `sentryEsbuildPlugin`. esbuild's single-pass tree-shaking keeps the (now dead) runtime injection in the bundle unlike webpack/vite/rollup, so this app only asserts the plain build bundles the runtime injection and the plugin build succeeds; the runtime-behavior side is covered separately. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Vite defaults to a browser target that rejects the entry's top-level await; set a node target. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mydea
force-pushed
the
fn/bundler-auto-exclude-channel-injection
branch
from
August 24, 2026 09:04
2e080ad to
9c7fdd7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stacked on #23475.
The
@sentry/nodebundler plugins (sentryRollupPlugin,sentryWebpackPlugin,sentryEsbuildPlugin,sentryVitePlugin) inject the orchestrion diagnostics channels at build time. When that is enabled — which is the default (buildTimeInstrumentation !== false) — the SDK's runtime channel injection is redundant.So the wrappers now default
bundleSizeOptimizations.excludeChannelInjectiontotrue, which sets__SENTRY_CHANNEL_INJECTION__ = false(from #23475) and tree-shakes the runtime hooks out of the build.excludeChannelInjectionalways wins, so it can be turned back on if needed.buildTimeInstrumentation: false, the default is skipped — runtime injection is then the only thing wiring up the channels.Shared via a small
withChannelInjectionExclusionDefaulthelper (bundler-plugin/common.ts) used by all four wrappers, with unit tests.🤖 Generated with Claude Code