Repository navigation
Conversation
Contributor
size-limit report 📦
|
…roxy Requests behind the proxy produce an extra route-less `GET` segment with op `http.server` next to the route segment. This test shows it for an API route and a page. Refs #25370 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Since Next.js 16.3 the proxy span is no longer a child of the `BaseServer.handleRequest` span that runs it, so that span became an empty `http.server` segment next to the one of the route. Drop it at span start in `beforeSampling`, based on the `middlewareInvoke` flag Next.js sets on the request. Its attributes at start are the same as the route's. For this, core now keeps the incoming request on the request's isolation scope and enforces the `beforeSampling` decision again, which it had stopped doing when `SentrySampler` was removed. Fixes #25370 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Instead of enforcing the `beforeSampling` decision in core, add a `beforeSpanStart` hook that runs right before `ignoreSpans` is checked and can change the name and attributes of a span. The Next.js SDK uses it to mark the request span that only runs the proxy with `sentry.drop_transaction`, which the existing Next.js `ignoreSpans` pattern drops. Refs #25370 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Lms24
force-pushed
the
lms/fix-nextjs-proxy-handle-request-segment
branch
from
October 16, 2026 15:27
a49a615 to
0453bca
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0453bca. Configure here.
…gment Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Instead of keeping the incoming request on a hidden field of the isolation scope in core, the Next.js SDK keeps it in its own map, filled from the `httpServerRequest` hook that the Node.js SDK emits for every incoming request. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Lms24
force-pushed
the
lms/fix-nextjs-proxy-handle-request-segment
branch
from
October 16, 2026 16:06
8c57d77 to
1a8666d
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.

Behind a proxy, Next.js runs each request through two
handleRequestcalls: one only runs the proxy, the other renders the route. Since Next.js 16.3 the proxy span is no longer a child of the first call's span, so that span became an emptyGETsegment with ophttp.server, counted next to the real one. We now drop it at span start withignoreSpans. At start, its name and attributes are the same as the real span's, so the only signal is themiddlewareInvokeflag Next.js sets on the request.For this, core gets a
beforeSpanStarthook that runs right beforeignoreSpansis checked and can change the span's name and attributes. Next.js uses it to mark the proxy-only span, and the existingsentry.drop_transactionignore pattern drops it. To read the flag, the Next.js SDK keeps the request of each isolation scope, from thehttpServerRequesthook of the Node.js SDK.Fixes #25370
🤖 Generated with Claude Code