Skip to content

fix(v10/cloudflare): keep default exports intact when auto-instrumenting - #25732

Merged
isaacs merged 3 commits into
backport/v10-25345-cloudflare-default-reexportfrom
backport/v10-25372-cloudflare-default-export-intact
Oct 26, 2026
Merged

isaacs merged 3 commits into
backport/v10-25345-cloudflare-default-reexportfrom
backport/v10-25372-cloudflare-default-export-intact

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Backport of: #25372

Stacked on #25407 (backport of #25345), which touches the same transform. Once #25407 merges, this retargets to v10.

Differences to the original PR

  • packages/cloudflare/test/vite/autoInstrument.test.ts: the four vinext tests (wraps the entry with @sentry/nextjs/cloudflare … and siblings) are left out. They come from feat(cloudflare): Wrap vinext Worker entries with @sentry/nextjs/cloudflare #25000, which isn't on v10. The other expectation updates in that file apply unchanged.
  • Extra fix on top, from a Bugbot review: the original found the end of the export default keywords with lastIndexOf('default') on the text before the expression, so a comment like export default /* default handler */ { ... } moved the overwrite past the keyword and produced invalid syntax. The keyword is now found by skipping whitespace and comments after export. develop still has the original code and needs the same fix.

via Junior system actor event.

--

View Junior Session [Sentry]

Backport of #25372. The vinext-specific tests in autoInstrument.test.ts
are left out because vinext support (#25000) is not on v10.

(cherry picked from commit 6b728c6)

Co-Authored-By: Isaac Schlueter <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.28 kB added added
@sentry/browser - with treeshaking flags 26.73 kB added added
@sentry/browser (incl. Tracing) 47.3 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 49.1 kB added added
@sentry/browser (incl. Tracing, Profiling) 52.09 kB added added
@sentry/browser (incl. Tracing, Replay) 86.75 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 76.38 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 91.46 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 104.08 kB added added
@sentry/browser (incl. Feedback) 45.45 kB added added
@sentry/browser (incl. sendFeedback) 33.09 kB added added
@sentry/browser (incl. FeedbackAsync) 38.21 kB added added
@sentry/browser (incl. Metrics) 29.38 kB added added
@sentry/browser (incl. Logs) 29.61 kB added added
@sentry/browser (incl. Metrics & Logs) 30.3 kB added added
@sentry/react 30.1 kB added added
@sentry/react (incl. Tracing) 49.6 kB added added
@sentry/vue 34.17 kB added added
@sentry/vue (incl. Tracing) 49.68 kB added added
@sentry/svelte 28.31 kB added added
CDN Bundle 30.69 kB added added
CDN Bundle (incl. Tracing) 49.25 kB added added
CDN Bundle (incl. Logs, Metrics) 32.28 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 50.57 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 71.75 kB added added
CDN Bundle (incl. Tracing, Replay) 86.99 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.27 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 92.8 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.08 kB added added
CDN Bundle - uncompressed 91.2 kB added added
CDN Bundle (incl. Tracing) - uncompressed 148.46 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 95.91 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.44 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 221.4 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 268.43 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.39 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 282.13 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.08 kB added added
@sentry/nextjs (client) 52.25 kB added added
@sentry/sveltekit (client) 47.75 kB added added
@sentry/core/server 81.66 kB added added
@sentry/core/browser 67.73 kB added added
@sentry/node-core 64.1 kB added added
@sentry/node 127.28 kB added added
@sentry/node (incl. diagnostics channel injection) 171.48 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B added added
@sentry/node/light 52.19 kB added added
@sentry/node - without tracing 75.89 kB added added
@sentry/aws-serverless 85.04 kB added added
@sentry/cloudflare (withSentry) - minified 204.93 kB added added
@sentry/cloudflare (withSentry) 505.2 kB added added

@isaacs
isaacs added this pull request to stack #25740 October 25, 2026 22:36
@isaacs
isaacs marked this pull request as ready for review October 25, 2026 22:36
@isaacs
isaacs requested a review from a team as a code owner October 25, 2026 22:36
@isaacs
isaacs requested review from andreiborza and isaacs and removed request for a team October 25, 2026 22:36

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 498856a. Configure here.

Comment thread packages/cloudflare/src/vite/transform.ts
A comment between `export default` and the expression that contained the
word `default` moved the overwrite past the keyword and produced invalid
syntax.
…cking regex

CodeQL flagged the comment-skipping regex as prone to exponential
backtracking. A linear scan over whitespace and comments finds the same
offset.
isaacs added a commit that referenced this pull request Oct 26, 2026
… the Vite transform (#25741)

The transform found the end of the `export default` keywords with
`lastIndexOf('default')` on the text before the expression. A comment in
that span that contains the word `default`, such as `export default /*
default handler */ { ... }`, moved the overwrite past the keyword and
produced invalid syntax, so the Worker failed to start.

The keyword is now found by matching `export`, then any whitespace or
comments, then `default`, starting at the statement. Acorn only gives an
`ExportDefaultDeclaration` when that sequence is there, so the match
always succeeds.

Cursor Bugbot found this on the v10 backport in #25732, which already
has the same fix.

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Isaac Schlueter <[email protected]>
@isaacs
isaacs merged commit 0cde423 into v10 Oct 26, 2026
163 of 166 checks passed
@isaacs
isaacs deleted the backport/v10-25372-cloudflare-default-export-intact branch October 26, 2026 15:36
isaacs added a commit that referenced this pull request Oct 26, 2026
…transform (#25733)

Backport of: #25663

Stacked on #25732 (backport of #25372), which is stacked on #25407. Once
those merge, this retargets to `v10`.

The cherry-pick applied cleanly and is identical to the original.

<!-- junior-request-attribution:start -->
via **Isaac Schlueter**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AD0CBUGS556X%3A1792966013.340469 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3AD0CBUGS556X%3A1792966013.340469)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0CBUGS556X%3A1792966013.340469/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Isaac Schlueter <[email protected]>
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