From 560bf39f17bf89d4bac547e20c61b3245ce67700 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 13 Jul 2019 22:46:41 +0200 Subject: [PATCH] streams: stop piping if dest has resposne --- lib/internal/streams/pipeline.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 798745a110d51b..07ecaea9794d50 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -50,7 +50,16 @@ function call(fn) { } function pipe(from, to) { - return from.pipe(to); + from.pipe(to); + + if (isRequest(to)) { + to.on('response', function() { + from.unpipe(this); + from.resume(); + }); + } + + return to; } function popCallback(streams) {