Skip to content

Turbopack build fails 'Failed to collect page data' on CMS-fed sitemap.xml (works with --webpack) #93144

@jobimdev

Description

@jobimdev

Description

In Next 16.2.3, when running next build (default Turbopack build) on a project that has app/sitemap.ts (and app/rss.xml/route.ts, app/llms.txt/route.ts) which fetch data from an external CMS (Sanity), the build fails while collecting page data:

Error: Failed to collect page data for /sitemap.xml
    at instantiateRuntimeModule (.next/server/chunks/[turbopack]_runtime.js:882:12)
    at getOrInstantiateRuntimeModule (.next/server/chunks/[turbopack]_runtime.js:895:12)

Interestingly, the same build succeeds when running via vercel build --prod on the Vercel build runner (identical Next version), and also succeeds locally when you pass next build --webpack explicitly.

So the bug appears to be specific to the local Turbopack build pipeline when the project also consumes @xyflow/react, framer-motion, and a CMS-fed sitemap.

Expected behavior

next build with default Turbopack should produce the same output as next build --webpack, and the static sitemap should be generated successfully.

Actual behavior

Build fails at the "collecting page data" stage for /sitemap.xml. The error stack points to Turbopack's runtime module loader.

Workaround

Use next build --webpack in package.json scripts. Local build succeeds in ~25s.

Environment

  • Next.js: 16.2.3
  • React: 19.2.4
  • Node: 20.x (Windows 10 and Vercel's Linux runner)
  • OS: Windows 10 (also reproduced intermittently on Vercel's Ubuntu build runner)

Relevant dependencies

  • @xyflow/react (interactive graph on /admin/jornada)
  • framer-motion@12.38.0
  • next-sanity@10.1.4 (consumed by app/sitemap.ts, app/rss.xml/route.ts, app/llms.txt/route.ts)
  • dagre@0.8.5

About app/sitemap.ts (essential — could not isolate a minimal repro yet)

Fetches all posts + courses from Sanity via the next-sanity client and returns an array of URLs. Nothing exotic.

Related

Couldn't find an exact duplicate after searching for "Turbopack sitemap collect page data". Closest ones:

Metadata

Metadata

Assignees

No one assigned

    Labels

    TurbopackRelated to Turbopack with Next.js.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions