Conversation
Contributor
size-limit report 📦
|
`withSentry` from `@sentry/nextjs/cloudflare` wraps the Worker entry of a Next.js app on Cloudflare Workers, e.g. `.open-next/worker.js` of OpenNext or the fetch handler of vinext. It is `withSentry` of `@sentry/cloudflare` with the Next.js handling added: - It installs the OpenTelemetry async context strategy and context manager at module load, so the spans of Next.js nest and keep their OpenTelemetry context as on Node.js. - Its client gets the span hooks and `ignoreSpans` of the server `init`, the `use cache` integration, the Sentry propagator and the Next.js SDK metadata. - The propagator keeps the request span as parent when Next.js extracts an incoming trace that the root span already continued. Next.js does this when it misses its router server context, e.g. on Workers where `process.cwd()` is `/bundle`, and each continued request then had two segments. - The request spans of Next.js (`BaseServer.handleRequest`) are ignored, so the request span of `withSentry` is the only `http.server` span. Next.js writes the route and status onto it, and the other Next.js spans become its children. - Requests to the tunnel route are not sampled. - The server and edge `init` in `sentry.*.config.ts` create no client in the Worker. They hand over the build release of `withSentryConfig`, which only code that Next.js compiles can read. The request root span of `@sentry/cloudflare` gets the route name of Next.js at span end, and middleware no longer renames a root span that Next.js did not start. The `nextjs-16-cf-workers` e2e app now uses it. This runs the server tests that were skipped, and adds tests for D1 spans, the OpenTelemetry context and trace continuation. Its `compatibility_date` moves to 2026-02-19, the first date on which Next.js extracts the incoming trace again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JPeer264
force-pushed
the
jp/nextjs-cloudflare-entry
branch
from
October 2, 2026 18:33
2ac09b0 to
fb54ebb
Compare
This branch has not been deployed
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.
Adds
withSentryfrom@sentry/nextjs/cloudflarefor the Worker entry of a Next.js app on Cloudflare Workers, for example.open-next/worker.jsof OpenNext or the fetch handler of vinext. It iswithSentryof@sentry/cloudflarewith the Next.js handling of the serverinitadded, so a Next.js app on Workers gets the spans it gets on Node.js from one wrapper, without new options. This is the only new public API.Decisions:
@sentry/cloudflareloses the OpenTelemetry context of the Next.js spans, so their parents and context values break.BaseServer.handleRequest) are ignored, so the request span ofwithSentryis the onlyhttp.serverspan. Next.js then writes the route and status onto it, and its other spans become its children.compatibility_date2026-02-19,process.cwd()is/bundleduring a request. Next.js then misses its router server context and extracts the incoming trace again. The propagator keeps the request span as parent in that case, else each continued request has two segments.sentry.server.config.tsandsentry.edge.config.tsstill run in the Worker but create no client there. They hand over the build release ofwithSentryConfig, which only code that Next.js compiles can read.@sentry/cloudflarebecomes a dependency of@sentry/nextjs. Its only new transitive dependency ismagic-string.Known limit: with
traceLifecycle: 'static', the request span keeps its URL name, because ignored spans stay inactive only with span streaming.The
nextjs-16-cf-workerse2e app now uses it, which un-skips its server tests and adds tests for D1 spans, the OpenTelemetry context and trace continuation.🤖 Generated with Claude Code