Skip to content

[Instrumentation] next dev --turbopack cold metadata fetch logs unexpected root span type ResolveMetadata.generateMetadata #91831

@reinaldosimoes

Description

@reinaldosimoes

Link to the code that reproduces this issue

https://github.com/reinaldosimoes/nextjs-resolvemetadata-root-span-repro

To Reproduce

  1. Clone the reproduction repo.
  2. Run npm install.
  3. Run npm run dev.
  4. Open http://localhost:3000/static-fetch as the first request after a fresh restart.
  5. Observe this warning in the terminal:
Unexpected root span type 'ResolveMetadata.generateMetadata'. Please report this Next.js issue https://github.com/vercel/next.js

Notes:

  • This repro is minimal and uses @sentry/nextjs instrumentation plus a page whose generateMetadata() performs a normal fetch(...).
  • If I warm the app by hitting another route first and then visit /static-fetch, the warning does not appear.
  • The second request to /static-fetch also does not warn.

Current vs. Expected behavior

Current behavior:

  • In next dev --turbopack, the first cold request to /static-fetch logs:
Unexpected root span type 'ResolveMetadata.generateMetadata'. Please report this Next.js issue https://github.com/vercel/next.js
GET /static-fetch 200 in 590ms (next.js: 133ms, application-code: 457ms)
  • The page still returns 200.

Expected behavior:

  • A normal generateMetadata() code path should not produce a warning about an unexpected root span type.
  • ResolveMetadata.generateMetadata appears to be a valid documented Next.js OTEL span type, so it seems like the root-span detection/context handling is incorrect in this cold-start path.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:46 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 25.5.0
  npm: 11.8.0
  Yarn: 1.22.19
  pnpm: 10.28.2
Relevant Packages:
  next: 16.2.1-canary.5 // Latest available version is detected (16.2.1-canary.5).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

Also reproduced on stable next@16.2.1.

Which area(s) are affected? (Select all that apply)

  • Instrumentation
  • Metadata
  • Turbopack

Which stage(s) are affected? (Select all that apply)

  • next dev (local)

Additional context

  • The public repro also reproduces on next@16.2.1-canary.5, not just stable 16.2.1.
  • I first saw this in a real app on next@16.2.0, then confirmed it still happened after upgrading to 16.2.1.
  • In the real app, the warning appeared on a localized weather page whose generateMetadata() did async work with fetch(...).
  • I narrowed the public repro down to the smallest case I could find:
    • App Router page
    • generateMetadata() does a normal await fetch("https://example.com")
    • @sentry/nextjs instrumentation active
    • next dev --turbopack
    • first request after restart
  • I also checked @sentry/nextjs@10.45.0; the warning still reproduces there.
  • It did not reproduce in my reduced repro when the metadata fetch used cache: "no-store".
  • This may be related to the recent OTEL parent/root-span work in:
  • Next.js OTEL docs list ResolveMetadata.generateMetadata as a valid span type:
    https://nextjs.org/docs/14/app/building-your-application/optimizing/open-telemetry

Metadata

Metadata

Assignees

No one assigned

    Labels

    InstrumentationRelated to Next.js Instrumentation.MetadataRelated to Next.js' Metadata API.TurbopackRelated to Turbopack with Next.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions