Skip to content

Fix onHeaders argument type in prerenderToNodeStream docs - #8720

Open
hsusul wants to merge 1 commit into
reactjs:mainfrom
hsusul:fix/prerendertonodestream-onheaders
Open

hsusul wants to merge 1 commit into
reactjs:mainfrom
hsusul:fix/prerendertonodestream-onheaders

Conversation

@hsusul

@hsusul hsusul commented Oct 30, 2026

Copy link
Copy Markdown

The prerenderToNodeStream reference says onHeaders "receives a [Headers] instance". It doesn't. The Node.js stream API passes a plain object with a Link property, the same as renderToPipeableStream. Only the Web Streams APIs (prerender, renderToReadableStream) wrap the descriptor in new Headers(...).

The source is packages/react-dom/src/server/ReactDOMFizzStaticNode.js. prerenderToNodeStream types the option as onHeaders?: (headers: HeadersDescriptor) => void and passes options.onHeaders straight through. prerender in the same file is the one that calls onHeaders(new Headers(headersDescriptor)).

The wrong sentence was copied from the Web Streams pages in #8632. This PR swaps in the wording renderToPipeableStream.md already uses for the same callback.

Code that follows the current docs and calls headers.get('Link') throws a TypeError ("headers.get is not a function").

Test plan

Ran against published react-dom@19.3.1 on Node 24.9.0, with a component that calls preconnect('https://example.com'):

static.node prerenderToNodeStream: [object Object] instanceofHeaders=false keys=["Link"] Link=<https://example.com>; rel=preconnect
static.node prerender: [object Headers] instanceofHeaders=true keys=[] Link=<https://example.com>; rel=preconnect
static.edge prerender: [object Headers] instanceofHeaders=true keys=[] Link=<https://example.com>; rel=preconnect
server.node renderToPipeableStream: [object Object] instanceofHeaders=false keys=["Link"] Link=<https://example.com>; rel=preconnect
server.edge renderToReadableStream: [object Headers] instanceofHeaders=true keys=[] Link=<https://example.com>; rel=preconnect

yarn lint, yarn tsc, yarn lint-heading-ids and yarn deadlinks pass.

@github-actions

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

This branch was successfully deployed

1 active deployment
Preview — ad2b4d32 Deployed Oct 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant