nextjs - 💡(How to fix) Fix [Instrumentation] next dev --turbopack cold metadata fetch logs unexpected root span type ResolveMetadata.generateMetadata [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#91831Fetched 2026-04-08 01:20:42
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
2
Participants
Timeline (top)
labeled ×3subscribed ×1

Error Message

  • The second request to /static-fetch also does not warn.

Code Example

Unexpected root span type 'ResolveMetadata.generateMetadata'. Please report this Next.js issue https://github.com/vercel/next.js

---

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)

---

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
RAW_BUFFERClick to expand / collapse

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 [email protected].

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 [email protected], not just stable 16.2.1.
  • I first saw this in a real app on [email protected], 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/[email protected]; 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:
    • #90832
    • #90840
  • Next.js OTEL docs list ResolveMetadata.generateMetadata as a valid span type: https://nextjs.org/docs/14/app/building-your-application/optimizing/open-telemetry

extent analysis

Fix Plan

To fix the issue with the unexpected root span type warning, we need to modify the generateMetadata function to handle the root span context correctly.

Here are the steps:

  • Update next to the latest version.
  • Modify the generateMetadata function to use cache: 'no-store' when making the fetch request.
  • If using @sentry/nextjs instrumentation, ensure it is updated to the latest version.

Example code:

export async function generateMetadata() {
  const response = await fetch('https://example.com', { cache: 'no-store' });
  // Process the response
}

Alternatively, you can also try to disable the @sentry/nextjs instrumentation for the generateMetadata function.

Verification

To verify that the fix worked, restart the development server and make a request to the /static-fetch page. The warning about the unexpected root span type should no longer appear in the terminal.

Extra Tips

  • Ensure that all dependencies, including next and @sentry/nextjs, are updated to the latest versions.
  • If the issue persists, try to reproduce it with a minimal example and report it to the Next.js issue tracker.
  • Refer to the Next.js OTEL documentation for more information on valid span types and how to handle root span context correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING