-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Description
Link to the code that reproduces this issue
https://github.com/vincent-turato/next.js
To Reproduce
-
Clone the reproduction repository:
git clone https://github.com/vincent-turato/next.js.git
cd next.js -
Check out the reproduction branch:
git checkout repro/streaming-html-suffix-bug -
Install dependencies:
pnpm install -
Build the Next.js packages:
pnpm build -
Run the failing test:
pnpm test packages/next/src/server/stream-utils/node-web-streams-helper.test.ts -
Observe the failure showing incorrect handling when the closing HTML suffix spans multiple stream chunks:
FAIL packages/next/src/server/stream-utils/node-web-streams-helper.test.ts
createMoveSuffixStream
✕ duplicates closing tags when suffix spans chunks● createMoveSuffixStream › duplicates closing tags when suffix spans
Expected: "Hello"
Received: "Hello"
Current vs. Expected behavior
Expected: "Hello"
Received: "Hello"
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #37~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 20 10:25:38 UTC 2
Available memory (MB): 23956
Available CPU cores: 16
Binaries:
Node: 22.19.0
npm: 10.9.3
Yarn: N/A
pnpm: 9.6.0
Relevant Packages:
next: 16.1.1-canary.7 // Latest available version is detected (16.1.1-canary.7).
eslint-config-next: N/A
react: 19.3.0-canary-65eec428-20251218
react-dom: 19.3.0-canary-65eec428-20251218
typescript: 5.9.2
Next.js Config:
output: N/AWhich area(s) are affected? (Select all that apply)
Loading UI and Streaming
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
Potential impacts of this issue include:
- Reliance on browser HTML error recovery during parsing, which can lead to subtle or undefined hydration behavior in SSR streaming paths (see https://nextjs.org/docs/messages/react-hydration-error).
- Emission of malformed or incomplete HTML during server-side streaming when document closing tags span multiple chunks.
- Missing
</body>and/or</html>tags in the streamed response under specific chunking conditions that do not occur in fully buffered renders.