{"record":{"id":"12feaaf31b703bca","repo":"facebook/react","slug":"react-currently-only-supports-piping-to-one-writab","errorCode":null,"errorMessage":"React currently only supports piping to one writable stream.","messagePattern":"React currently only supports piping to one writable stream\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js","lineNumber":204,"sourceCode":"    options ? options.identifierPrefix : undefined,\n    options ? options.temporaryReferences : undefined,\n    options ? options.startTime : undefined,\n    __DEV__ && options ? options.environmentName : undefined,\n    __DEV__ && options ? options.filterStackFrame : undefined,\n    debugChannelReadable !== undefined,\n  );\n  let hasStartedFlowing = false;\n  startWork(request);\n  if (debugChannelWritable !== undefined) {\n    startFlowingDebug(request, debugChannelWritable);\n  }\n  if (debugChannelReadable !== undefined) {\n    startReadingFromDebugChannelReadable(request, debugChannelReadable);\n  }\n  return {\n    pipe<T: Writable>(destination: T): T {\n      if (hasStartedFlowing) {\n        throw new Error(\n          'React currently only supports piping to one writable stream.',\n        );\n      }\n      hasStartedFlowing = true;\n      startFlowing(request, destination);\n      destination.on('drain', createDrainHandler(destination, request));\n      destination.on(\n        'error',\n        createCancelHandler(\n          request,\n          'The destination stream errored while writing data.',\n        ),\n      );\n      // We don't close until the debug channel closes.\n      if (!__DEV__ || debugChannelReadable === undefined) {\n        destination.on(\n          'close',\n          createCancelHandler(request, 'The destination stream closed early.'),","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js#L186-L222","documentation":"renderToPipeableStream in this package returns a handle with pipe() and abort(). React's Flight server writes each request to exactly one Writable; a hasStartedFlowing flag makes a second pipe() on the same handle throw instead of interleaving two output streams and corrupting the payload.","triggerScenarios":"Calling pipe() twice on one result of renderToPipeableStream — piping to the HTTP response and then also to a cache/log stream, retry logic that re-pipes after a failure, or both a request handler and a shutdown hook calling pipe on the same handle.","commonSituations":"Frameworks that want to tee the payload (response plus prefetch cache); error-recovery middleware that re-pipes; tests piping one render into several sinks.","solutions":["Render once per destination: call renderToPipeableStream again for each additional Writable","Tee manually by forwarding the first destination's chunk events to the second sink","Wrap pipe in a once-guard so a second call is rejected with your own clear error"],"exampleFix":"// before\nconst {pipe} = renderToPipeableStream(<App/>, opts);\npipe(httpResponse);\npipe(logStream); // throws: second pipe\n\n// after — one render per destination\nrenderToPipeableStream(<App/>, opts).pipe(httpResponse);\nrenderToPipeableStream(<App/>, opts).pipe(logStream);","handlingStrategy":"validation","validationCode":"export function pipeOnce(request) {\n  let piped = false;\n  return {\n    pipe(destination) {\n      if (piped) throw new Error('pipe() already called — render again for another destination');\n      piped = true;\n      return request.pipe(destination);\n    },\n    abort(reason) {\n      request.abort(reason);\n    },\n  };\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call pipe exactly once per renderToPipeableStream result","Render again for each additional destination instead of re-piping","Tee at the transport layer (forward chunks) if you must duplicate output"],"tags":["streaming","ssr","react-server-components","render-to-pipeable-stream"],"backgroundTag":"pipe-to-multiple-streams","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}