Skip to content

feat(cloudflare): Add allow list to enableRpcTracePropagation - #23363

Open
JPeer264 wants to merge 1 commit into
jp/rpc-revertfrom
jp/rpc-allow-list
Open

feat(cloudflare): Add allow list to enableRpcTracePropagation#23363
JPeer264 wants to merge 1 commit into
jp/rpc-revertfrom
jp/rpc-allow-list

Conversation

@JPeer264

Copy link
Copy Markdown
Member

This adds an allow list to enableRpcTracePropagation the accepts an array of strings and regular expressions. The createRpcPropagationResolver returns a function so inside the Proxy we don't have to go over the if's over and over (as the config doesn't change dynamically).

This closes #23233, but I'd like to add one more feature into the stack: That our Vite plugin is automatically allow listing bindings within the same deployment, as these are safe to be added (we know for sure that these are instrumented with Sentry and RPC trace propagation is ok to have)

@JPeer264 JPeer264 self-assigned this Aug 12, 2026
@JPeer264
JPeer264 requested a review from a team as a code owner August 12, 2026 13:26
@JPeer264
JPeer264 requested review from andreiborza, isaacs, mydea and s1gr1d and removed request for a team, isaacs and mydea August 12, 2026 13:26
@github-actions

github-actions Bot commented Aug 12, 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.34 kB - -
@sentry/browser - with treeshaking flags 28.51 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.85 kB - -
@sentry/browser (incl. Tracing) 48.56 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.57 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.45 kB - -
@sentry/browser (incl. Tracing, Replay) 87.97 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.35 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.69 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.37 kB - -
@sentry/browser (incl. Feedback) 47.66 kB - -
@sentry/browser (incl. sendFeedback) 35.16 kB - -
@sentry/browser (incl. FeedbackAsync) 40.31 kB - -
@sentry/browser (incl. Metrics) 31.31 kB - -
@sentry/browser (incl. Logs) 31.58 kB - -
@sentry/browser (incl. Metrics & Logs) 32.25 kB - -
@sentry/react 32.13 kB - -
@sentry/react (incl. Tracing) 50.77 kB - -
@sentry/vue 35.35 kB - -
@sentry/vue (incl. Tracing) 50.51 kB - -
@sentry/svelte 30.37 kB - -
CDN Bundle 31.64 kB - -
CDN Bundle (incl. Tracing) 48.89 kB - -
CDN Bundle (incl. Logs, Metrics) 33.86 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.85 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.38 kB - -
CDN Bundle (incl. Tracing, Replay) 86.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.34 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.19 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.16 kB - -
CDN Bundle - uncompressed 93.94 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.76 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.34 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.56 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.28 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.02 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.81 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.72 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.49 kB - -
@sentry/nextjs (client) 53.29 kB - -
@sentry/sveltekit (client) 48.98 kB - -
@sentry/core/server 65.44 kB - -
@sentry/core/browser 51.8 kB - -
@sentry/node 117.97 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 82.09 kB - -
@sentry/aws-serverless 91.5 kB - -
@sentry/cloudflare (withSentry) - minified 214.28 kB +0.1% +212 B 🔺
@sentry/cloudflare (withSentry) 529.55 kB +0.13% +663 B 🔺

View base workflow run

Comment on lines 94 to 100
return instrumented;
}

if (!options?.enableRpcTracePropagation) {
if (!shouldPropagateRpcTrace(String(prop))) {
return item;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The module-level instrumentedBindings cache is checked before the shouldPropagateRpcTrace predicate, causing cached bindings to bypass RPC propagation rules on subsequent requests with different configurations.
Severity: MEDIUM

Suggested Fix

The order of operations should be changed. The shouldPropagateRpcTrace predicate should be checked before attempting to retrieve a binding from the instrumentedBindings cache. This ensures that the current invocation's configuration is always respected, even if a cached version of the binding exists from a previous invocation with a different configuration.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/cloudflare/src/instrumentations/worker/instrumentEnv.ts#L94-L100

Potential issue: A module-level cache, `instrumentedBindings`, stores instrumented RPC
bindings. This cache is checked before the `shouldPropagateRpcTrace` predicate is
evaluated. If an RPC binding is accessed with a permissive configuration (e.g.,
`enableRpcTracePropagation: true`), it is instrumented and cached. A subsequent
invocation with a more restrictive configuration will hit the cache and return the
already-instrumented binding, bypassing the new configuration's allow-list check. This
results in unintended trace propagation for RPC calls.

Did we get this right? 👍 / 👎 to inform future reviews.

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.

Cloudflare RPC trace propagation changes method arguments for uninstrumented receivers

1 participant