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:
Description
In Next 16.2.3, when running
next build(default Turbopack build) on a project that hasapp/sitemap.ts(andapp/rss.xml/route.ts,app/llms.txt/route.ts) which fetch data from an external CMS (Sanity), the build fails while collecting page data:Interestingly, the same build succeeds when running via
vercel build --prodon the Vercel build runner (identical Next version), and also succeeds locally when you passnext build --webpackexplicitly.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 buildwith default Turbopack should produce the same output asnext 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 --webpackinpackage.jsonscripts. Local build succeeds in ~25s.Environment
Relevant dependencies
@xyflow/react(interactive graph on/admin/jornada)framer-motion@12.38.0next-sanity@10.1.4(consumed byapp/sitemap.ts,app/rss.xml/route.ts,app/llms.txt/route.ts)dagre@0.8.5About
app/sitemap.ts(essential — could not isolate a minimal repro yet)Fetches all posts + courses from Sanity via the
next-sanityclient 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:
robots.txtgeneration fromrobots.tsfails withoutput: "export"config in Next 15 RC & Canary.108 #68667 — robots.txt generation issue (different cause)