Search code examples
node.jsstreambackpressure

Does Node stream.pipeline also provides back-pressuring prevention?


The answer to this question is perhaps one word. The documentation here is kind of confusing: in the beginning it introduces the stream.pipeline() method as even a more preferable version of .pipe method, but later on it focuses solely on the .pipe method as a method that provides back-pressuring prevention mechanism. The Node official doc also clearly mentions .pipe as having back-pressuring prevention mechanism, but says no such thing about the pipeline method. So: does pipeline (as a supposedly improved version of .pipe) does the same regulating thing to prevent back-pressuring in a pipeline? I hope so. Cheers!


Solution

  • Yes, pipeline() handles back pressure. It's basically .pipe() with a LOT better error handling and a more flexible programming interface.