Metadata descriptions containing Windows carriage returns result in duplicate <meta> tags
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/henrycatalinismith/carriage-return-duplicate-description-bug-demo
To Reproduce
- Build the demo app
- Run it
- Load the front page at http://localhost:3000/
- Run document.querySelectorAll('meta[name="description"]').length in the console
Current vs. Expected behavior
It should say 1. It says 2 instead because the Windows carriage return has been stripped in the built version of the HTML but not in the data that the page is hydrated with. This causes Next to re-add the description during hydration, leading to a duplicate tag albeit with slightly different content due to the presence of the Windows carriage return in the second one.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:31:56 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T6030
Available memory (MB): 36864
Available CPU cores: 12
Binaries:
Node: 24.12.0
npm: 11.6.2
Yarn: 1.22.22
pnpm: 10.32.1
Relevant Packages:
next: 16.2.4 // Latest available version is detected (16.2.4).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.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)
Other (Deployed)
Additional context
A workaround is to run output from generateMetadata though replace(/\r/g, '') to strip out the Windows carriage returns.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked carriage-return duplicate-description demo: build and run it, load the front page, and inspect document.querySelectorAll('meta[name="description"]'). Compare the built HTML with the data used during hydration, focusing on generateMetadata and the Windows carriage return. Done means the reproduction produces one description meta tag without requiring the documented workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs, react
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100