Skip to content

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

Draft
JPeer264 wants to merge 1 commit into
developfrom
jp/rpc-allow-list
Draft

feat(cloudflare): Add allow list to enableRpcTracePropagation#23363
JPeer264 wants to merge 1 commit into
developfrom
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 📦

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.89 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.18 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.12 kB - -
CDN Bundle - uncompressed 93.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.74 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.08 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.7 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.37 kB - -
@sentry/core/browser 51.7 kB - -
@sentry/node 117.14 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 81.43 kB -0.01% -1 B 🔽
@sentry/aws-serverless 90.92 kB - -
@sentry/cloudflare (withSentry) - minified 214.21 kB +0.11% +225 B 🔺
@sentry/cloudflare (withSentry) 529.61 kB +0.14% +690 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.

Base automatically changed from jp/rpc-revert to develop August 13, 2026 08:29
Comment on lines +36 to 38
// receiver has no Sentry to strip a trailing metadata argument.
enableRpcTracePropagation: ['SUB_WORKER', 'SUB_WORKER_NO_PROPAGATION'],
}),

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 integration test for RPC trace propagation incorrectly includes 'SUB_WORKER_NO_PROPAGATION' in the enableRpcTracePropagation allowlist, contradicting the test's goal of verifying behavior for a disabled binding.
Severity: LOW

Suggested Fix

To align the test's behavior with its stated purpose, remove 'SUB_WORKER_NO_PROPAGATION' from the enableRpcTracePropagation allowlist within the test's configuration. This will ensure the test correctly validates that trace metadata is not injected when propagation is disabled.

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:
dev-packages/cloudflare-integration-tests/suites/tracing/propagation/worker-workerentrypoint-rpc/index.ts#L36-L38

Potential issue: An integration test for RPC trace propagation has a configuration
error. The test, named "does not inject RPC trace metadata into receiver calls when
enableRpcTracePropagation is disabled", is meant to verify that trace metadata is not
injected for a disabled binding. However, the test configuration explicitly includes the
binding `'SUB_WORKER_NO_PROPAGATION'` in the `enableRpcTracePropagation` allowlist. The
test currently passes because the receiver worker is also instrumented and strips the
metadata, but this means the test is not validating its stated purpose. It's testing
that metadata is stripped, not that it isn't injected in the first place.

@JPeer264
JPeer264 marked this pull request as draft August 14, 2026 09:46
@JPeer264

Copy link
Copy Markdown
Member Author

Currently rethinking. It might make more sense to get rid of enableRpcTracePropagation entirely in v11 and actually focus on rpcTracePropagationTargets instead which only allows Array<string>. This would actually align with tracePropagationTargets. The reason for this is, that a boolean for enableRpcTracePropagation would almost never make sense and the rpcTracePropagationTargets for the same deployment would be enabled by default. The behavior would be similar to what we have for tracePropagationTargets (https://docs.sentry.io/platforms/javascript/guides/cloudflare/tracing/instrumentation/automatic-instrumentation/#tracePropagationTargets): Only allow localhost and everything that starts with / (so everything in the same deployment).

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