nextjs - ✅(Solved) Fix next 16.0.1 won't pass build with `export default async function sitemap({ id }: { id: string })` [1 pull requests, 6 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

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#85632Fetched 2026-04-08 02:14:50
View on GitHub
Comments
6
Participants
4
Timeline
27
Reactions
0
Author
Timeline (top)
commented ×6labeled ×4referenced ×4mentioned ×3

Error Message

Error occurred prerendering page "/sitemap/pages.xml". Read more: https://nextjs.org/docs/messages/prerender-error TypeError: id.includes is not a function at parsePaginatedId (.next/server/app/sitemap/[metadata_id]/route.js:136:12) at sitemap_sitemap (.next/server/app/sitemap/[metadata_id]/route.js:151:28) at GET (.next/server/app/sitemap/[metadata_id]/route.js:242:22) Export encountered an error on /sitemap/[metadata_id]/route: /sitemap/pages.xml, exiting the build. ⨯ Next.js build worker exited with code: 1 and signal: null error: script "build" exited with code 1 Error: Command "bun run build" exited with 1

Fix Action

Fix / Workaround

Workaround:

PR fix notes

PR #85701: docs: update multi sitemap argumenmt type

Description (problem / solution / changelog)

In v16, id argument in metadata routes becomes promise which requries to to unwrap it first to access the value

Follow up of #84491

Closes #85632

Changed files

  • docs/01-app/02-guides/upgrading/version-16.mdx (modified, +31/-0)
  • docs/01-app/03-api-reference/03-file-conventions/01-metadata/sitemap.mdx (modified, +6/-5)

Code Example

Error occurred prerendering page "/sitemap/pages.xml". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: id.includes is not a function
    at parsePaginatedId (.next/server/app/sitemap/[__metadata_id__]/route.js:136:12)
    at sitemap_sitemap (.next/server/app/sitemap/[__metadata_id__]/route.js:151:28)
    at GET (.next/server/app/sitemap/[__metadata_id__]/route.js:242:22)
Export encountered an error on /sitemap/[__metadata_id__]/route: /sitemap/pages.xml, exiting the build.
  Next.js build worker exited with code: 1 and signal: null
error: script "build" exited with code 1
Error: Command "bun run build" exited with 1

---

sitemap: Promise {
    ,
    [Symbol(async_id_symbol)]: 67959,
    ...
  }

---

export default async function sitemap({ id }: { id: string }): Promise<MetadataRoute.Sitemap> {
    const { type, page } = parsePaginatedId(id); // id should be string, but is Promise in 16.0.1
    // ...
  }

  export function parsePaginatedId(id: string): { page?: number; type: SitemapType } {
    if (id.includes('-')) { // TypeError: id.includes is not a function
      // ...
    }
    return { type: id as SitemapType };
  }

---

Operating System:
    Platform: darwin
    Arch: arm64
    Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
    Available memory (MB): 65536
    Available CPU cores: 10
  Binaries:
    Node: 22.15.0
    npm: 10.9.2
    Yarn: N/A
    pnpm: 10.18.3
  Relevant Packages:
    next: 16.0.1
    react: 19.2.0
    react-dom: 19.2.0
    typescript: 5.9.3
  Next.js Config:
    output: N/A

---

export default async function sitemap({ id }: { id: Promise<string> }): Promise<MetadataRoute.Sitemap> {
    const idValue = await id; // unwrap Promise
    const { type, page } = parsePaginatedId(idValue);
    // ...
  }
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/lobehub/lobe-chat

To Reproduce

  1. Clone the next-16 branch: git clone -b next-16 https://github.com/lobehub/lobe-chat.git
  2. Install dependencies: bun install (or pnpm install)
  3. Run production build: bun run build
  4. Build worker exits with prerender error

Current vs. Expected behavior

with next16.0.1 ,it failed when building:

Error occurred prerendering page "/sitemap/pages.xml". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: id.includes is not a function
    at parsePaginatedId (.next/server/app/sitemap/[__metadata_id__]/route.js:136:12)
    at sitemap_sitemap (.next/server/app/sitemap/[__metadata_id__]/route.js:151:28)
    at GET (.next/server/app/sitemap/[__metadata_id__]/route.js:242:22)
Export encountered an error on /sitemap/[__metadata_id__]/route: /sitemap/pages.xml, exiting the build.
 ⨯ Next.js build worker exited with code: 1 and signal: null
error: script "build" exited with code 1
Error: Command "bun run build" exited with 1

I have tried to run in dev mode with /sitemap/pages.xml url, and find some details:

In Next.js 16.0.1, the id parameter passed to the sitemap function is a Promise object rather than a string:

  sitemap: Promise {
    ,
    [Symbol(async_id_symbol)]: 67959,
    ...
  }

This causes the following error when trying to use string methods on it:

TypeError: id.includes is not a function at parsePaginatedId (src/app/sitemap.tsx:40:10) at sitemap (src/app/sitemap.tsx:54:26)

Expected Behavior:

The id parameter should be a string (as it was in Next.js 15.x), allowing direct string operations like id.includes(), id.split(), etc.

Code that works in Next.js 15 but breaks in 16:

export default async function sitemap({ id }: { id: string }): Promise<MetadataRoute.Sitemap> {
  const { type, page } = parsePaginatedId(id); // id should be string, but is Promise in 16.0.1
  // ...
}

export function parsePaginatedId(id: string): { page?: number; type: SitemapType } {
  if (id.includes('-')) { // TypeError: id.includes is not a function
    // ...
  }
  return { type: id as SitemapType };
}

Provide environment information

Operating System:
    Platform: darwin
    Arch: arm64
    Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
    Available memory (MB): 65536
    Available CPU cores: 10
  Binaries:
    Node: 22.15.0
    npm: 10.9.2
    Yarn: N/A
    pnpm: 10.18.3
  Relevant Packages:
    next: 16.0.1
    react: 19.2.0
    react-dom: 19.2.0
    typescript: 5.9.3
  Next.js Config:
    output: N/A

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

Metadata, Turbopack

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

next dev (local), next build (local)

Additional context

This appears to be a breaking change between Next.js 15.x and 16.0.1. The sitemap API's id parameter type has changed from string to Promise<string> without documentation or migration guide.

Workaround:

Adding await to unwrap the Promise:

  export default async function sitemap({ id }: { id: Promise<string> }): Promise<MetadataRoute.Sitemap> {
    const idValue = await id; // unwrap Promise
    const { type, page } = parsePaginatedId(idValue);
    // ...
  }

However, this breaks the documented API contract where id is supposed to be a string according to the https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap.

extent analysis

TL;DR

The most likely fix is to await the id parameter in the sitemap function to unwrap the Promise and access the string value.

Guidance

  • The error occurs because the id parameter is a Promise object in Next.js 16.0.1, whereas it was a string in Next.js 15.x.
  • To fix this, you can modify the sitemap function to await the id parameter, like this: const idValue = await id;.
  • Then, pass the unwrapped idValue to the parsePaginatedId function.
  • Note that this change may break the documented API contract, so consider reviewing the Next.js documentation for any updates or migration guides.

Example

export default async function sitemap({ id }: { id: Promise<string> }): Promise<MetadataRoute.Sitemap> {
  const idValue = await id; // unwrap Promise
  const { type, page } = parsePaginatedId(idValue);
  // ...
}

Notes

  • This fix assumes that the id parameter is always a Promise that resolves to a string.
  • If the id parameter can be null or undefined, you may need to add additional error handling.
  • It's recommended to review the Next.js documentation and any related issues or pull requests to ensure this fix is compatible with your use case.

Recommendation

Apply the workaround by awaiting the id parameter in the sitemap function, as it provides a temporary solution to the breaking change in Next.js 16.0.1. However, keep an eye on the Next.js documentation and issues for any official fixes or migration guides.

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

nextjs - ✅(Solved) Fix next 16.0.1 won't pass build with `export default async function sitemap({ id }: { id: string })` [1 pull requests, 6 comments, 4 participants]