| 3314 | dest.on('drain', ondrain); |
| 3315 | |
| 3316 | function cleanup() { |
| 3317 | // cleanup event handlers once the pipe is broken |
| 3318 | dest.removeListener('close', onclose); |
| 3319 | dest.removeListener('finish', onfinish); |
| 3320 | dest.removeListener('drain', ondrain); |
| 3321 | dest.removeListener('error', onerror); |
| 3322 | dest.removeListener('unpipe', onunpipe); |
| 3323 | src.removeListener('end', onend); |
| 3324 | src.removeListener('end', cleanup); |
| 3325 | |
| 3326 | // if the reader is waiting for a drain event from this |
| 3327 | // specific writer, then it would cause it to never start |
| 3328 | // flowing again. |
| 3329 | // So, if this is awaiting a drain, then we just call it now. |
| 3330 | // If we don't know, then assume that we are waiting for one. |
| 3331 | if (!dest._writableState || dest._writableState.needDrain) |
| 3332 | ondrain(); |
| 3333 | } |
| 3334 | |
| 3335 | // if the dest has an error, then stop piping into it. |
| 3336 | // however, don't suppress the throwing behavior for this. |