Skip to content

sitemap.xml with route handler and force-static breaks build — regression 16.1.7 → 16.2.0 #94041

@jordihm9

Description

@jordihm9

Link to the code that reproduces this issue

https://github.com/jordihm9/nextjs-repro-94024

To Reproduce

  1. Fork the project
  2. Create a project on Vercel
  3. Link the project with the project
  4. Create a deployment
  5. Check deployment failure and error

Current vs. Expected behavior

Expected: [store]/[lang]/c/sitemap.xml is recognized as a standalone route handler and registered in the app output map — as it was in 16.1.7.
Actual — with dynamic = "force-static": build fails with:

Error: Invariant: failed to find source route /[store]/[lang]/c/sitemap.xml for prerender /[store]/[lang]/c/sitemap.xml

Actual — with dynamic = "auto": build succeeds but [store]/[lang]/c/sitemap.xml is not registered in the app output map. At runtime the request is matched against [store]/[lang]/c/[slug] instead, and params arrive URL-encoded:

[ '%5Bstore%5D', '%5Blang%5D', '%5Bslug%5D' ]

instead of the expected { store: 'en', lang: 'en' }.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:33:09 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T8112
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 22.22.3
  npm: 10.9.8
  Yarn: N/A
  pnpm: 11.1.3
Relevant Packages:
  next: 16.2.6 // Latest available version is detected (16.2.6).
  eslint-config-next: N/A
  react: 19.2.6
  react-dom: 19.2.6
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Route Groups, Route Handlers

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

Vercel (Deployed)

Additional context

  • sitemap.xml may be treated as a keyword. Renaming the folder from sitemap.xml to any arbitrary name (e.g. asd.xml) fixes both the build failure and the param encoding issue. This may indicate sitemap.xml triggers a special path resolution case, though it could also be coincidental given that renaming also avoids the slug collision.
  • Root-level *-sitemap.xml route handlers work fine. Several route handlers at the app root without dynamic parent segments (e.g. product-sitemap.xml/route.ts, collection-sitemap.xml/route.ts) work correctly in all versions. The bug is isolated to sitemap.xml under dynamic parent segments with a sibling [slug] route.
  • A llms.txt route handler at the same [store]/[lang] level works fine. It shares the same dynamic parent segments but has no inner route group and no sibling dynamic [slug]. Both conditions appear necessary to trigger the bug: nested route groups and a sibling [slug route at the same level.
  • Only consistently reproducible on Vercel (3 parallel build workers). Local next build succeeds in all cases, pointing to a race condition in app output map registration during parallel prerendering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions