feat(nitro): Add a Cloudflare Workers plugin - #23246
Open
adipascu wants to merge 1 commit into
Open
Conversation
adipascu
force-pushed
the
feat/nitro-cloudflare-plugin
branch
3 times, most recently
from
August 11, 2026 10:58
34b9f59 to
0b5bae1
Compare
adipascu
marked this pull request as ready for review
August 11, 2026 11:00
adipascu
requested review from
chargome and
s1gr1d
and removed request for
a team
August 11, 2026 11:00
adipascu
marked this pull request as draft
August 11, 2026 11:01
adipascu
force-pushed
the
feat/nitro-cloudflare-plugin
branch
2 times, most recently
from
August 11, 2026 11:26
7c4df55 to
e490372
Compare
adipascu
marked this pull request as ready for review
August 11, 2026 12:05
adipascu
force-pushed
the
feat/nitro-cloudflare-plugin
branch
2 times, most recently
from
August 11, 2026 14:26
a2df7b1 to
2dca239
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2dca239. Configure here.
adipascu
force-pushed
the
feat/nitro-cloudflare-plugin
branch
from
August 11, 2026 14:38
2dca239 to
35d55b8
Compare
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.

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint) & (yarn test).What
Adds a Cloudflare Workers build to
@sentry/nitro, so Nitro apps on a Workers preset get server-side capture through@sentry/cloudflare.sentryCloudflareNitroPlugin(optionsOrFn)mirrors the existing@sentry/nuxtplugin API, and resolves its options on each request so a DSN from a request-scoped binding is picked up.@sentry/nitro/cloudflareand through theworkerdandworkerconditions, with the entry atsrc/cloudflare/index.ts. Nitro's Cloudflare presets resolveworkerd, andworkercovers bundlers that use the broader condition, following@sentry/nextjsand@sentry/tanstackstart-react.ExecutionContextfromrequest.runtime.cloudflare.context, where Nitro v3 puts it, and warns once instead of staying silent when a request carries none (nitro dev, non-Workers presets).waitUntil, and reuses the existingcaptureErrorHookfor Nitro'serrorhook.@sentry/cloudflaretodependencies, matching@sentry/nuxtand@sentry/sveltekit.The change is additive: the Node entry keeps its exports and behaviour.
Root
typespoints at the Node build, and eachworkerd/workerbranch carries the Cloudflare declarations, so a TS setup with a matching custom condition resolves types that agree with the runtime module. The other packages use a combinedindex.types.d.ts, but generating one here would drop most of the@sentry/nodesurface throughexport *collisions, so the Cloudflare entry keeps its own types instead. Happy to add the combined entry if you would prefer it.Related: #23029, #20038.
Why
@sentry/nitroresolves to@sentry/nodeunder every condition today, so acloudflare-modulepreset has no supported path to server-side capture from this SDK. Nuxt already ships a Workers plugin, and Nitro is the layer both sit on, so the capability belongs here.Testing
Unit tests cover the plugin, including that the options are re-read per request. One test walks the
@sentry/nitro/cloudflaremodule graph and asserts it stays clear of@sentry/node, since #22519 hit that class of bug through a barrel re-export and it is invisible at build time.A new
nitro-3-cloudflaree2e app builds thecloudflare-modulepreset and serves it underwrangler dev. It asserts that a thrown route error arrives from the Workers runtime as an HTTP 500 with theErrorlinked to its h3HTTPErrorwrapper andhandled: false, that a handled request produces anhttp.servertransaction withoriginauto.http.cloudflare, and that 404s are not reported.Aside: I am currently available for JavaScript/TypeScript contracting or full-time work. Contact: adrian@pascu.be.