Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/elastic-wave-5d4hkj?workspaceId=b7d16bab-058a-4b6f-b4f8-cb3182273009
To Reproduce
- Create a new Next.js app with
npx create-next-app@latest (accept all the default settings)
- Create a new
app/sitemap.ts file
- Copy and paste the example from: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap#generating-a-sitemap-using-code-js-ts. This will work when you visit
localhost:3000/sitemap.xml
- Now, copy and paste the localized example: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap#generate-a-localized-sitemap. This will not work. Remove all the alternates, and it works again.
Current vs. Expected behavior
We would expect to see a sitemap with localized alternates when we visit localhost:3000/sitemap.xml. Instead, visiting this route results in a plain text result, with a Uncaught TypeError: Cannot read properties of null (reading 'childNodes') error in the browser console.

Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Available memory (MB): 4102
Available CPU cores: 2
Binaries:
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 15.0.0-canary.37 // Latest available version is detected (15.0.0-canary.37).
eslint-config-next: N/A
react: 19.0.0-rc-6f23540c7d-20240528
react-dom: 19.0.0-rc-6f23540c7d-20240528
typescript: 5.3.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Metadata
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
This issue is a duplicate of: #65817
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/elastic-wave-5d4hkj?workspaceId=b7d16bab-058a-4b6f-b4f8-cb3182273009
To Reproduce
npx create-next-app@latest(accept all the default settings)app/sitemap.tsfilelocalhost:3000/sitemap.xmlCurrent vs. Expected behavior
We would expect to see a sitemap with localized alternates when we visit
localhost:3000/sitemap.xml. Instead, visiting this route results in a plain text result, with aUncaught TypeError: Cannot read properties of null (reading 'childNodes')error in the browser console.Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023 Available memory (MB): 4102 Available CPU cores: 2 Binaries: Node: 20.9.0 npm: 9.8.1 Yarn: 1.22.19 pnpm: 8.10.2 Relevant Packages: next: 15.0.0-canary.37 // Latest available version is detected (15.0.0-canary.37). eslint-config-next: N/A react: 19.0.0-rc-6f23540c7d-20240528 react-dom: 19.0.0-rc-6f23540c7d-20240528 typescript: 5.3.3 Next.js Config: output: N/AWhich area(s) are affected? (Select all that apply)
Metadata
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
This issue is a duplicate of: #65817