diff --git a/lib/stream.js b/lib/stream.js index fa45b8b1e15..d6da2525f95 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -52,12 +52,8 @@ Stream.prototype.pipe = function(dest, options) { dest.on('drain', ondrain); // If the 'end' option is not supplied, dest.end() will be called when - // source gets the 'end' or 'close' events. Only dest.end() once, and - // only when all sources have ended. + // source gets the 'end' or 'close' events. Only dest.end() once. if (!dest._isStdio && (!options || options.end !== false)) { - dest._pipeCount = dest._pipeCount || 0; - dest._pipeCount++; - source.on('end', onend); source.on('close', onclose); } @@ -67,16 +63,9 @@ Stream.prototype.pipe = function(dest, options) { if (didOnEnd) return; didOnEnd = true; - dest._pipeCount--; - // remove the listeners cleanup(); - if (dest._pipeCount > 0) { - // waiting for other incoming streams to end. - return; - } - dest.end(); } @@ -85,16 +74,9 @@ Stream.prototype.pipe = function(dest, options) { if (didOnEnd) return; didOnEnd = true; - dest._pipeCount--; - // remove the listeners cleanup(); - if (dest._pipeCount > 0) { - // waiting for other incoming streams to end. - return; - } - dest.destroy(); } diff --git a/test/simple/test-stream-pipe-cleanup.js b/test/simple/test-stream-pipe-cleanup.js index c2df97019ba..aa504c41644 100644 --- a/test/simple/test-stream-pipe-cleanup.js +++ b/test/simple/test-stream-pipe-cleanup.js @@ -77,16 +77,6 @@ assert.equal(limit, w.endCalls); w.endCalls = 0; -var r2; -r = new Readable(); -r2 = new Readable(); - -r.pipe(w); -r2.pipe(w); -r.emit('close'); -r2.emit('close'); -assert.equal(1, w.endCalls); - r = new Readable(); for (i = 0; i < limit; i++) {