Skip to content

feat(nextjs)!: Use middleware span op for Next.js middleware - #22674

Merged
chargome merged 1 commit into
developfrom
feat/nextjs-middleware-span-op
Jul 27, 2026
Merged

feat(nextjs)!: Use middleware span op for Next.js middleware#22674
chargome merged 1 commit into
developfrom
feat/nextjs-middleware-span-op

Conversation

@chargome

@chargome chargome commented Jul 27, 2026

Copy link
Copy Markdown
Member

Aligns the Next.js middleware span op with the @sentry/conventions middleware, replacing the previous http.server.middleware.

The duplicate middleware span this issue also described was already resolved separately in #18456 (the build-time wrapper no longer starts its own span); this PR adds the regression test coverage that was missing there.

closes #22636

@chargome chargome self-assigned this Jul 27, 2026
@chargome

chargome commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

curslinger 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6180813. Configure here.

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.95 kB - -
@sentry/browser - with treeshaking flags 26.39 kB - -
@sentry/browser (incl. Tracing) 46.41 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.18 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.21 kB - -
@sentry/browser (incl. Tracing, Replay) 85.69 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.33 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.4 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.06 kB - -
@sentry/browser (incl. Feedback) 45.13 kB - -
@sentry/browser (incl. sendFeedback) 32.74 kB - -
@sentry/browser (incl. FeedbackAsync) 37.8 kB - -
@sentry/browser (incl. Metrics) 29.04 kB - -
@sentry/browser (incl. Logs) 29.26 kB - -
@sentry/browser (incl. Metrics & Logs) 29.97 kB - -
@sentry/react 29.71 kB - -
@sentry/react (incl. Tracing) 48.68 kB - -
@sentry/vue 33.38 kB - -
@sentry/vue (incl. Tracing) 48.4 kB - -
@sentry/svelte 27.97 kB - -
CDN Bundle 30.28 kB - -
CDN Bundle (incl. Tracing) 48.26 kB - -
CDN Bundle (incl. Logs, Metrics) 31.85 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.58 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 71.13 kB - -
CDN Bundle (incl. Tracing, Replay) 85.83 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.14 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.6 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.89 kB - -
CDN Bundle - uncompressed 90.15 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.22 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.86 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.2 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.62 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.46 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.42 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.16 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.11 kB - -
@sentry/nextjs (client) 51.23 kB - -
@sentry/sveltekit (client) 46.84 kB - -
@sentry/core/server 80.05 kB - -
@sentry/core/browser 52.01 kB - -
@sentry/node 112.66 kB - -
@sentry/node (incl. diagnostics channel injection) 156.79 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 62.19 kB - -
@sentry/aws-serverless 72.46 kB - -
@sentry/cloudflare (withSentry) - minified 197.05 kB - -
@sentry/cloudflare (withSentry) 484.73 kB - -

View base workflow run

Aligns the Next.js middleware span op with the `@sentry/conventions`
`WEB_SERVER_MIDDLEWARE_SPAN_OP` (`middleware`), replacing the previous
`http.server.middleware`. The mixed `http.server`-family op was problematic
for span streaming and description inference.

Also adds regression coverage asserting the middleware wrapper does not start
its own span (the duplicate was already removed in #18456).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chargome
chargome force-pushed the feat/nextjs-middleware-span-op branch from 1e77052 to b769481 Compare July 27, 2026 12:07
@chargome
chargome marked this pull request as ready for review July 27, 2026 12:23
@chargome
chargome requested a review from a team as a code owner July 27, 2026 12:23
@chargome
chargome requested review from Lms24, nicohrubec and s1gr1d and removed request for a team July 27, 2026 12:23
@chargome
chargome merged commit 66f9d56 into develop Jul 27, 2026
78 checks passed
@chargome
chargome deleted the feat/nextjs-middleware-span-op branch July 27, 2026 12:29
chargome added a commit that referenced this pull request Jul 27, 2026
Discovered in #22674
that this was not running on webpack so here we go.

I added a reusable helper to aggregate streamed spans for e2e tests

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Duplicate http.server.middleware spans emitted for Next.js middleware

2 participants