fix(v10/cloudflare): Auto-instrument classes re-exported from the worker entry - #24181
Open
JPeer264 wants to merge 2 commits into
Open
fix(v10/cloudflare): Auto-instrument classes re-exported from the worker entry#24181JPeer264 wants to merge 2 commits into
JPeer264 wants to merge 2 commits into
Conversation
Contributor
size-limit report 📦
|
…ker entry Backport of: #23282
JPeer264
force-pushed
the
backport-v10-cloudflare-reexport-autoinstrument
branch
from
September 8, 2026 07:27
3111724 to
64067a8
Compare
JPeer264
marked this pull request as ready for review
September 8, 2026 09:36
JPeer264
requested review from
isaacs and
mydea
and removed request for
a team
September 8, 2026 09:36
Comment on lines
+519
to
+523
| wrapLocalClassExport(localName, localClass, kind, ctx, state); | ||
| state.wrappedClasses.add(exportedName); | ||
| state.needsImport = true; | ||
| return undefined; | ||
| } |
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of: #23282
Differences to the original PR
packages/cloudflare/test/vite/autoInstrument.test.ts: the three new agent re-export expectations includeenableRpcTracePropagation: 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: theInstrumentedClass+markAsInstrumentedchange was applied on top of the v10 generic signatures. v10 does not have theDefaultEnv/ResolveEnv/StrictCloudflareOptionsgenerics 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.