Skip to content

feat(cloudflare): Derive rpcTracePropagationTargets from the wrangler config - #23491

Draft
JPeer264 wants to merge 1 commit into
jp/rpc-trace-propagation-targetsfrom
jp/rpc-trace-propagation-targets-vite
Draft

feat(cloudflare): Derive rpcTracePropagationTargets from the wrangler config#23491
JPeer264 wants to merge 1 commit into
jp/rpc-trace-propagation-targetsfrom
jp/rpc-trace-propagation-targets-vite

Conversation

@JPeer264

Copy link
Copy Markdown
Member

The Vite plugin already knows which bindings resolve to receivers it instruments itself: Durable Object bindings without a script_name, and service bindings naming this worker. Those are exactly the bindings whose trailing trace argument is guaranteed to be stripped again, so the plugin adds them to rpcTracePropagationTargets and same-deployment RPC traces connect without any configuration. Bindings to other workers stay opt-in.

Only bindings whose receiver class the transform wrapped itself are added. A class the user wrapped by hand, or re-exported from another module, runs on its own options and cannot be assumed to strip the argument.

The options object only exists once the callback runs with env, so the plugin cannot merge at build time. The transform emits an inline callback that wraps the user's one and merges the binding names, so no runtime helper export is needed.

Note this default only applies to Vite builds. At runtime a DurableObjectNamespace exposes no origin and a Fetcher does not say which service it points at, so a plain wrangler build still has to list its bindings.

… config

The Vite plugin already knows which bindings resolve to receivers it instruments
itself: Durable Object bindings without a `script_name`, and service bindings
naming this worker. Those are exactly the bindings whose trailing trace argument is
guaranteed to be stripped again, so the plugin adds them to
`rpcTracePropagationTargets` and same-deployment RPC traces connect without any
configuration. Bindings to other workers stay opt-in.

Only bindings whose receiver class the transform wrapped itself are added. A class
the user wrapped by hand, or re-exported from another module, runs on its own
options and cannot be assumed to strip the argument.

The options object only exists once the callback runs with `env`, so the plugin
cannot merge at build time. The transform emits an inline callback that wraps the
user's one and merges the binding names, so no runtime helper export is needed.

Note this default only applies to Vite builds. At runtime a DurableObjectNamespace
exposes no origin and a Fetcher does not say which service it points at, so a plain
wrangler build still has to list its bindings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JPeer264 JPeer264 self-assigned this Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

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.58 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.59 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.46 kB - -
@sentry/browser (incl. Tracing, Replay) 87.98 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.36 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.7 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.39 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.77 kB - -
@sentry/vue 35.34 kB - -
@sentry/vue (incl. Tracing) 50.54 kB - -
@sentry/svelte 30.33 kB - -
CDN Bundle 31.61 kB - -
CDN Bundle (incl. Tracing) 48.9 kB - -
CDN Bundle (incl. Logs, Metrics) 33.8 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.82 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.31 kB - -
CDN Bundle (incl. Tracing, Replay) 86.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.31 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.19 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.12 kB - -
CDN Bundle - uncompressed 93.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.75 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.44 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.08 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.01 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.71 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.37 kB - -
@sentry/nextjs (client) 53.29 kB - -
@sentry/sveltekit (client) 49 kB - -
@sentry/core/server 65.38 kB - -
@sentry/core/browser 51.72 kB - -
@sentry/node 117.47 kB +0.02% +23 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 82 kB +0.03% +21 B 🔺
@sentry/aws-serverless 91.37 kB +0.03% +27 B 🔺
@sentry/cloudflare (withSentry) - minified 194.43 kB +0.05% +88 B 🔺
@sentry/cloudflare (withSentry) 480.93 kB +0.09% +399 B 🔺

View base workflow run

@JPeer264

Copy link
Copy Markdown
Member Author

bugbot run

@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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a85e9fb. Configure here.

// MagicString positions are always relative to the original source.
state.ms.overwrite(node.start, decl.start, 'const __SENTRY_DEFAULT_EXPORT__ = ');
state.ms.append(`\nexport default __SENTRY__.withSentry(${ctx.optionsFn}, __SENTRY_DEFAULT_EXPORT__);\n`);
state.ms.append(`\nexport default __SENTRY__.withSentry(${state.optionsFn}, __SENTRY_DEFAULT_EXPORT__);\n`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missed self-binding on default re-export

Medium Severity

When export default AlreadyWrappedClass skips wrapping because the class was already auto-wrapped as a named export, undefined is never added to autoWrapped. Entrypoint-less self service bindings use className: undefined, so they are filtered out of rpcTracePropagationTargets even though the default export is the instrumented class and would strip the trailing RPC metadata.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a85e9fb. 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