silverwolf-x/project / packages /next /src /server /app-render /debug-channel-server.node.ts
silverwolf-x's picture
download
raw
1.12 kB
/**
* Node debug channel implementation.
* Loaded by debug-channel-server.ts when __NEXT_USE_NODE_STREAMS is enabled.
*/
import { PassThrough, Writable } from 'node:stream'
import type { DebugChannelPair } from './debug-channel-server.web'
export { createWebDebugChannel } from './debug-channel-server.web'
/**
* Creates a debug channel using Node.js streams.
* Use with renderToNodeFlightStream (React's renderToPipeableStream),
* which expects debugChannel to be a Node.js stream with a .write() method.
*/
export function createNodeDebugChannel(): DebugChannelPair {
const readable = new PassThrough()
// Use a plain Writable instead of exposing the PassThrough directly.
// React's renderToPipeableStream detects .read() on the debugChannel and
// enters bidirectional mode, reading its own output back as commands.
const writable = new Writable({
write(chunk, _encoding, callback) {
readable.push(chunk)
callback()
},
final(callback) {
readable.push(null)
callback()
},
})
return {
serverSide: writable,
clientSide: { readable },
}
}

Xet Storage Details

Size:
1.12 kB
·
Xet hash:
5fc7c322c49bda751da518288d3e8b13ae0929c2acd458fa8a8c32f8a1678760

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.