Skip to content

Cloudflare RPC trace propagation changes method arguments for uninstrumented receivers #23233

Description

@matthew-gizmo

Environment

  • @sentry/cloudflare: 10.69.0
  • Cloudflare Workers service-binding RPC
  • Caller: wrapped with Sentry.withSentry()
  • Receiver: plain, uninstrumented WorkerEntrypoint

Description

With enableRpcTracePropagation: true, the Cloudflare SDK propagates trace context for RPC method calls by appending a trailing { __sentry_rpc_meta__: ... } argument.

A receiver wrapped by Sentry removes that argument before invoking application code. A plain receiver does not, so enabling Sentry on the caller changes the receiver's application-visible RPC arguments.

This can occur during gradual deployments, rollbacks, mixed SDK versions, or when an instrumented Worker calls a service that does not use Sentry.

Minimal reproduction

Define an uninstrumented receiver with an optional trailing parameter:

import { WorkerEntrypoint } from "cloudflare:workers";

export default class Receiver extends WorkerEntrypoint {
  inspect(first: string, second: string, optionalTimeoutMs?: number) {
    return {
      first,
      second,
      optionalArgumentType: typeof optionalTimeoutMs,
      receivedSentryMetadata:
        typeof optionalTimeoutMs === "object" &&
        optionalTimeoutMs !== null &&
        "__sentry_rpc_meta__" in optionalTimeoutMs,
    };
  }
}

Wrap only the caller and enable RPC trace propagation:

export default Sentry.withSentry(
  env => ({
    dsn: env.SENTRY_DSN,
    tracesSampleRate: 1,
    enableRpcTracePropagation: true,
  }),
  Caller,
);

From an active sampled trace, call:

await env.RECEIVER.inspect("first", "second");

Actual behavior

The receiver observes a third object argument containing __sentry_rpc_meta__. In this example, optionalArgumentType is "object" rather than "undefined".

This can silently alter behavior. For example, if an optional numeric argument is passed to setTimeout, the metadata object may be coerced into an immediate timeout.

Expected behavior

Enabling tracing on a caller should not change the receiver's application-visible RPC arguments. If mixed instrumentation cannot preserve RPC semantics, the SDK should fail safely or provide a clear runtime/configuration warning rather than forwarding internal metadata into application parameters.

Additional context

The SDK documentation says both sides should enable this option for full trace propagation. That explains why an instrumented receiver can extract the metadata, but it does not make mixed deployments safe: caller-only instrumentation currently changes the RPC method contract rather than merely losing trace continuity.

Possible directions include an out-of-band propagation mechanism, mixed-version-safe negotiation, or an explicit guard/warning when safe receiver extraction cannot be guaranteed.

Metadata

Metadata

Assignees

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions