Skip to content

fix(cloudflare): auto-instrument a re-exported default export - #25345

Open
isaacs wants to merge 1 commit into
isaacschlueter/js-3725-sentrycloudflarevite-auto-instrumentation-skips-the-workerfrom
isaacs/auto-instrument-default-export-re-exported
Open

isaacs wants to merge 1 commit into
isaacschlueter/js-3725-sentrycloudflarevite-auto-instrumentation-skips-the-workerfrom
isaacs/auto-instrument-default-export-re-exported

Conversation

@isaacs

@isaacs isaacs commented Oct 14, 2026

Copy link
Copy Markdown
Member

The Vite plugin did not wrap a Worker entry whose default export comes from another module:

export { default } from './handler';
export { handler as default } from './handler';

The transform now imports the handler under a private name, wraps it with withSentry, and exports the wrapper as the default.

The handler may already be wrapped in its own module, which the build cannot see. So the wrap goes through _INTERNAL_wrapUnlessInstrumented, the same guard that class re-exports use. For a handler object, a second withSentry call adds nothing anyway, because each method is patched only once.

@isaacs
isaacs added this pull request to stack #25346 October 14, 2026 03:02
The Vite plugin did not wrap a Worker entry whose default export comes
from another module:

```js
export { default } from './handler';
export { handler as default } from './handler';
```

The transform now imports the handler under a private name, wraps it
with `withSentry`, and exports the wrapper as the default.

The handler may already be wrapped in its own module, which the build
cannot see. So the wrap goes through `_INTERNAL_wrapUnlessInstrumented`,
the same guard that class re-exports use. For a handler object, a second
`withSentry` call adds nothing anyway, because each method is patched
only once.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@isaacs
isaacs force-pushed the isaacs/auto-instrument-default-export-re-exported branch from 2f1ee75 to 3dbce98 Compare October 14, 2026 04:03
@isaacs
isaacs marked this pull request as ready for review October 14, 2026 04:03
@isaacs
isaacs requested a review from a team as a code owner October 14, 2026 04:03
@isaacs
isaacs requested review from JPeer264 and mydea and removed request for a team October 14, 2026 04:03

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

great catch.

This branch has not been deployed

No deployments
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.

2 participants