vercel/next.js · error
Unexpected root span type '${rootSpanAttributes.get('next.sp
Error message
Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js What it means
Post-response telemetry sanity check in Server.handleRequest (base-server.ts): after finishing a request it reads the OTEL root span attributes via tracer.getRootSpanAttributes() and expects next.span_type to be BaseServerSpan.handleRequest. Any other value means tracing instrumentation wrapped the request wrongly (custom tracer setup or nested spans) — a Next.js-internal inconsistency, hence the request to report it.
Source
Thrown at packages/next/src/server/base-server.ts:917
if (res.statusCode && res.statusCode >= 500) {
// For 5xx status codes: SHOULD be set to 'Error' span status.
// x-ref: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
span.setStatus({
code: SpanStatusCode.ERROR,
})
// For span status 'Error', SHOULD set 'error.type' attribute.
span.setAttribute('error.type', res.statusCode.toString())
}
const rootSpanAttributes = tracer.getRootSpanAttributes()
// We were unable to get attributes, probably OTEL is not enabled
if (!rootSpanAttributes) return
if (
rootSpanAttributes.get('next.span_type') !==
BaseServerSpan.handleRequest
) {
console.warn(
`Unexpected root span type '${rootSpanAttributes.get(
'next.span_type'
)}'. Please report this Next.js issue https://github.com/vercel/next.js`
)
return
}
const route = rootSpanAttributes.get('next.route')
if (route) {
const name = isRSCRequest
? `RSC ${method} ${route}`
: `${method} ${route}`
span.setAttributes({
'next.route': route,
'http.route': route,
'next.span_name': name,
})View on GitHub (pinned to 258b1c1bc0)
Solutions
- Report the issue at https://github.com/vercel/next.js with a reproduction; this indicates an internal tracing bug.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/next/src/server/base-server.ts:910 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of vercel/next.js@258b1c1bc0 (2026-08-19).
Data as JSON: /api/errors/e36b4baf09cd8efc.
Report an issue: GitHub.