diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 3c5434cb9e483e..5267c447e3826a 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -6,7 +6,6 @@ const { ArrayIsArray, Promise, - MathMax, SymbolAsyncIterator, } = primordials; @@ -322,7 +321,7 @@ function pipelineImpl(streams, callback, opts) { return ret; } -function pipe (src, dst) { +function pipe(src, dst) { if (typeof src.read !== 'function') { src.pipe(dst); return; @@ -334,7 +333,7 @@ function pipe (src, dst) { dst .on('drain', pump); - function end () { + function end() { dst.end(); } @@ -345,13 +344,14 @@ function pipe (src, dst) { dst._writableState?.objectMode ); - function pump () { + function pump() { if (dst.writableNeedDrain) { return; } while (true) { - const chunk = src.read((!objectMode && dst.writableHighwaterMark) || undefined); + const n = (!objectMode && dst.writableHighwaterMark) || undefined; + const chunk = src.read(n); if (chunk === null || !dst.write(chunk)) { return; }