Skip to content

feat(cloudflare): Wrap vinext Worker entries with @sentry/nextjs/cloudflare - #25000

Open
JPeer264 wants to merge 1 commit into
jp/nextjs-16-runtime-variantsfrom
jp/cloudflare-vite-vinext-nextjs-entry
Open

JPeer264 wants to merge 1 commit into
jp/nextjs-16-runtime-variantsfrom
jp/cloudflare-vite-vinext-nextjs-entry

Conversation

@JPeer264

@JPeer264 JPeer264 commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

part of #19514
part of JS-1803

When a Vite build uses vinext and @sentry/nextjs/cloudflare resolves from the Worker entry, the Vite plugin of @sentry/cloudflare now wraps the entry with withSentry from @sentry/nextjs/cloudflare. Other builds, and versions of @sentry/nextjs without that entry, keep @sentry/cloudflare.

-import * as __SENTRY__ from '@sentry/cloudflare';
+import * as __SENTRY__ from '@sentry/nextjs/cloudflare';
 const __SENTRY_DEFAULT_EXPORT__ = { fetch() { ... } };
 export default __SENTRY__.withSentry(() => undefined, __SENTRY_DEFAULT_EXPORT__);

Why

With withSentry of @sentry/cloudflare, a vinext app on Workers sends Cloudflare data but no Next.js spans. Now it gets the Next.js spans without a config change.

Traces

The same app and requests: vinext on Workers before and after this PR, and next start on Node.js.

Request vinext before vinext after Next.js on Node.js
GET /parameterized/42 GET, 1 span GET /parameterized/[id], 7 spans GET /parameterized/[id], 7 spans
GET /api/hello GET, 1 span GET /api/hello, 4 spans GET /api/hello, 4 spans
GET /api/throw (error) GET, 1 span GET /api/throw, 3 spans GET /api/throw, 3 spans

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.72 kB - -
@sentry/browser - with treeshaking flags 27.86 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.75 kB - -
@sentry/browser (incl. Tracing) 51.75 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.75 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.73 kB - -
@sentry/browser (incl. Tracing, Replay) 91.44 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.34 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 96.14 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 109.15 kB - -
@sentry/browser (incl. Feedback) 47.24 kB - -
@sentry/browser (incl. sendFeedback) 34.77 kB - -
@sentry/browser (incl. FeedbackAsync) 39.85 kB - -
@sentry/browser (incl. Metrics) 30.72 kB - -
@sentry/browser (incl. Logs) 31.01 kB - -
@sentry/browser (incl. Metrics & Logs) 31.67 kB - -
@sentry/react 31.54 kB - -
@sentry/react (incl. Tracing) 54.07 kB - -
@sentry/vue 37.75 kB - -
@sentry/vue (incl. Tracing) 54.67 kB - -
@sentry/svelte 29.74 kB - -
@sentry/remix (Remix 3 client bundle) 56.76 kB - -
CDN Bundle 31.43 kB - -
CDN Bundle (incl. Tracing) 52.28 kB - -
CDN Bundle (incl. Logs, Metrics) 33.64 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 54.23 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.53 kB - -
CDN Bundle (incl. Tracing, Replay) 89.91 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.86 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.06 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.05 kB - -
CDN Bundle - uncompressed 92.72 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.25 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.25 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 161.21 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.22 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 275.35 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 281.29 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.05 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 294.98 kB - -
@sentry/nextjs (client) 56.45 kB - -
@sentry/sveltekit (client) 52.14 kB - -
@sentry/core/server 40.85 kB - -
@sentry/core/browser 13.71 kB - -
@sentry/node 145.87 kB +0.01% +8 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.33 kB - -
@sentry/node - without tracing 93.66 kB +0.02% +10 B 🔺
@sentry/node - without channel injection 124.01 kB +0.02% +13 B 🔺
@sentry/aws-serverless 101.88 kB -0.01% -5 B 🔽
@sentry/cloudflare (withSentry) - minified 209.67 kB - -
@sentry/cloudflare (withSentry) 519.89 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 227.34 kB added added

View base workflow run

@JPeer264
JPeer264 force-pushed the jp/cloudflare-vite-vinext-nextjs-entry branch from f3f2a5f to 6d76b74 Compare October 2, 2026 18:33
@JPeer264
JPeer264 force-pushed the jp/cloudflare-vite-vinext-nextjs-entry branch 2 times, most recently from 28a0224 to 3a6835c Compare October 3, 2026 16:14
@JPeer264
JPeer264 added this pull request to stack #25035 October 5, 2026 08:43
@JPeer264
JPeer264 force-pushed the jp/cloudflare-vite-vinext-nextjs-entry branch from 3a6835c to 08ff431 Compare October 5, 2026 09:13
@JPeer264

JPeer264 commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@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 08ff431. Configure here.

Comment thread packages/cloudflare/test/vite/autoInstrument.test.ts
@JPeer264
JPeer264 force-pushed the jp/cloudflare-vite-vinext-nextjs-entry branch from 08ff431 to d5649bc Compare October 5, 2026 11:15
@JPeer264
JPeer264 force-pushed the jp/cloudflare-vite-vinext-nextjs-entry branch from d5649bc to 85e1ba3 Compare October 6, 2026 06:42
@JPeer264
JPeer264 force-pushed the jp/cloudflare-vite-vinext-nextjs-entry branch 2 times, most recently from 57d753d to 96ee28c Compare October 6, 2026 09:28
@JPeer264
JPeer264 force-pushed the jp/cloudflare-vite-vinext-nextjs-entry branch from 96ee28c to 9baf158 Compare October 6, 2026 12:57
@JPeer264
JPeer264 force-pushed the jp/cloudflare-vite-vinext-nextjs-entry branch 3 times, most recently from 1c9f1fe to 87fce49 Compare October 6, 2026 15:31
@JPeer264 JPeer264 self-assigned this Oct 7, 2026
@JPeer264
JPeer264 marked this pull request as ready for review October 7, 2026 14:44
@JPeer264
JPeer264 requested a review from a team as a code owner October 7, 2026 14:44
@JPeer264
JPeer264 requested review from andreiborza, chargome, logaretm and mydea and removed request for a team, andreiborza and mydea October 7, 2026 14:44
…udflare`

`sentryCloudflareVitePlugin` wrapped the Worker entry of a vinext app with
`withSentry` of `@sentry/cloudflare`, so the app sent Cloudflare data but no
Next.js spans. In a build with the vinext plugins, the generated code now
imports from `@sentry/nextjs/cloudflare` when it resolves from the entry.
Other builds, and vinext builds without `@sentry/nextjs`, keep
`@sentry/cloudflare`. Vite throws instead of returning `null` when
`@sentry/nextjs` is installed in a version without the `./cloudflare` entry,
so a throw of the resolve counts as unresolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/cloudflare-vite-vinext-nextjs-entry branch from 87fce49 to a42fd95 Compare October 7, 2026 16:26

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