fix: bridge web debug channel to Node Writable for renderToPipeableStream
React's Node API (renderToPipeableStream) expects debugChannel to be a
Node.js Writable (typeof .write === 'function'), Duplex, or WebSocket.
Next.js creates the debug channel with a web WritableStream inside
{ writable: WritableStream }, which the web API extracts via
options.debugChannel.writable, but the Node API checks the object itself.
When the Node API sees debugChannel !== undefined but can't find .write(),
it enables debug info production (pendingDebugChunks++) without setting
up a debug destination. Debug chunks accumulate indefinitely, the request
never completes, and the flight stream hangs.
The fix: in renderToFlightPipeableStream, detect the web-style debug
channel shape ({ writable: WritableStream }) and bridge it to a Node.js
Writable that forwards chunks via the web WritableStream's locked writer.
React then sees .write() on the object and uses it as the debug
destination, allowing pendingDebugChunks to drain and the request to
complete normally.
Re-enables debugChannel at all five renderToFlightPipeableStream call
sites that were temporarily disabled.
Showing
Please
register
or
sign in
to comment