Skip to content

fix(v10/cloudflare): Auto-instrument classes re-exported from the worker entry - #24181

Open
JPeer264 wants to merge 2 commits into
v10from
backport-v10-cloudflare-reexport-autoinstrument
Open

fix(v10/cloudflare): Auto-instrument classes re-exported from the worker entry#24181
JPeer264 wants to merge 2 commits into
v10from
backport-v10-cloudflare-reexport-autoinstrument

Conversation

@JPeer264

@JPeer264 JPeer264 commented Sep 7, 2026

Copy link
Copy Markdown
Member

Backport of: #23282

Differences to the original PR

  • packages/cloudflare/test/vite/autoInstrument.test.ts: the three new agent re-export expectations include enableRpcTracePropagation: opts?.enableRpcTracePropagation ?? true, in the generated __SENTRY_OPTIONS__ snippet. v10 still emits that property, develop does not, so the strings had to match the v10 output (identical to the existing expectation in the same file).
  • packages/cloudflare/src/durableobject.ts, packages/cloudflare/src/workflows.ts: the InstrumentedClass + markAsInstrumented change was applied on top of the v10 generic signatures. v10 does not have the DefaultEnv / ResolveEnv / StrictCloudflareOptions generics refactor, so those signatures stay as they are on v10; the behavior change is the same.
  • dev-packages/cloudflare-integration-tests/runner.ts: receivedEnvelopes.push(envelope) was added next to the v10 wording of the surrounding waiter comment.

The behavior of the fix is unchanged, all deviations are adaptations to the older code shape.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.76 kB added added
@sentry/browser - with treeshaking flags 26.2 kB added added
@sentry/browser (incl. Tracing) 46.62 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 48.41 kB added added
@sentry/browser (incl. Tracing, Profiling) 51.38 kB added added
@sentry/browser (incl. Tracing, Replay) 85.88 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.5 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 90.61 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 103.25 kB added added
@sentry/browser (incl. Feedback) 44.94 kB added added
@sentry/browser (incl. sendFeedback) 32.56 kB added added
@sentry/browser (incl. FeedbackAsync) 37.69 kB added added
@sentry/browser (incl. Metrics) 28.85 kB added added
@sentry/browser (incl. Logs) 29.07 kB added added
@sentry/browser (incl. Metrics & Logs) 29.77 kB added added
@sentry/react 29.57 kB added added
@sentry/react (incl. Tracing) 48.88 kB added added
@sentry/vue 33.18 kB added added
@sentry/vue (incl. Tracing) 48.59 kB added added
@sentry/svelte 27.79 kB added added
CDN Bundle 30.15 kB added added
CDN Bundle (incl. Tracing) 48.58 kB added added
CDN Bundle (incl. Logs, Metrics) 31.73 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 49.88 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 71.02 kB added added
CDN Bundle (incl. Tracing, Replay) 86.1 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.41 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 91.9 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 93.18 kB added added
CDN Bundle - uncompressed 89.89 kB added added
CDN Bundle (incl. Tracing) - uncompressed 146.7 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.6 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.68 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.43 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 266 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.97 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.7 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.66 kB added added
@sentry/nextjs (client) 51.43 kB added added
@sentry/sveltekit (client) 47.04 kB added added
@sentry/core/server 80.8 kB added added
@sentry/core/browser 66.95 kB added added
@sentry/node-core 63.33 kB added added
@sentry/node 126.02 kB added added
@sentry/node (incl. diagnostics channel injection) 170.11 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B added added
@sentry/node/light 51.47 kB added added
@sentry/node - without tracing 75 kB added added
@sentry/aws-serverless 84.26 kB added added
@sentry/cloudflare (withSentry) - minified 202.76 kB added added
@sentry/cloudflare (withSentry) 499.38 kB added added

@JPeer264
JPeer264 force-pushed the backport-v10-cloudflare-reexport-autoinstrument branch from 3111724 to 64067a8 Compare September 8, 2026 07:27
@JPeer264
JPeer264 marked this pull request as ready for review September 8, 2026 09:36
@JPeer264
JPeer264 requested a review from a team as a code owner September 8, 2026 09:36
@JPeer264
JPeer264 requested review from isaacs and mydea and removed request for a team September 8, 2026 09:36
@JPeer264 JPeer264 self-assigned this Sep 8, 2026
@JPeer264
JPeer264 requested a review from andreiborza September 8, 2026 09:36
Comment thread packages/cloudflare/src/vite/autoInstrument.ts Outdated
Comment on lines +519 to +523
wrapLocalClassExport(localName, localClass, kind, ctx, state);
state.wrappedClasses.add(exportedName);
state.needsImport = true;
return undefined;
}

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: Locally-declared classes exported via a specifier list are not added to state.autoWrapped, causing them to miss RPC trace propagation bindings when sameWorkerBindings is used.
Severity: MEDIUM

Suggested Fix

After the wrapLocalClassExport call within the wrapCrossModuleSpecifier function, add state.autoWrapped.add(exportedName);. This will ensure locally-declared, specifier-exported classes are correctly registered for auto-wrapping features like RPC trace propagation, restoring the previous behavior.

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/vite/transform.ts#L519-L523

Potential issue: In `wrapCrossModuleSpecifier`, when a locally-declared class is
exported via a specifier list (e.g., `class MyDO {}; export { MyDO };`), it is correctly
added to `state.wrappedClasses` but is not added to `state.autoWrapped`. The
`buildMergedOptionsDeclaration` function relies on `state.autoWrapped` to identify which
bindings should receive `rpcTracePropagationBindings` when the `sameWorkerBindings`
feature is enabled. Because the class is missing from `state.autoWrapped`, it will no
longer have RPC trace propagation enabled. This is a functional regression, as the
previous implementation correctly included these classes.

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