| 141 | startWork(request); |
| 142 | return { |
| 143 | pipe<T: Writable>(destination: T): T { |
| 144 | if (hasStartedFlowing) { |
| 145 | throw new Error( |
| 146 | 'React currently only supports piping to one writable stream.', |
| 147 | ); |
| 148 | } |
| 149 | hasStartedFlowing = true; |
| 150 | prepareForStartFlowingIfBeforeAllReady(request); |
| 151 | startFlowing(request, destination); |
| 152 | destination.on('drain', createDrainHandler(destination, request)); |
| 153 | destination.on( |
| 154 | 'error', |
| 155 | createCancelHandler( |
| 156 | request, |
| 157 | 'The destination stream errored while writing data.', |
| 158 | ), |
| 159 | ); |
| 160 | destination.on( |
| 161 | 'close', |
| 162 | createCancelHandler(request, 'The destination stream closed early.'), |
| 163 | ); |
| 164 | return destination; |
| 165 | }, |
| 166 | abort(reason: mixed) { |
| 167 | abort(request, reason); |
| 168 | }, |