From 9088822a3ea33e53ee89b956b14b9f52acc25b7c Mon Sep 17 00:00:00 2001 From: Eldar Gabdullin Date: Tue, 25 Jun 2013 23:53:12 +0400 Subject: [PATCH 1/2] fix: do not hang on sync END event --- common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.js b/common.js index ac226ea..b663b1e 100644 --- a/common.js +++ b/common.js @@ -86,13 +86,13 @@ function streamToSink(stream, end) { } function onRead(err, chunk) { - reading = false; if (chunk === undefined) { if (end) stream.end(); if (err) stream.destroy(); callback(err); } else { + reading = false; writing = !stream.write(chunk); check(); } From 6a327e90dedc8b9afb88c9f4c4625732ca7f2abd Mon Sep 17 00:00:00 2001 From: Eldar Gabdullin Date: Tue, 25 Jun 2013 23:58:02 +0400 Subject: [PATCH 2/2] Do not call .end() on error --- common.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common.js b/common.js index b663b1e..d5a0ba3 100644 --- a/common.js +++ b/common.js @@ -87,8 +87,12 @@ function streamToSink(stream, end) { function onRead(err, chunk) { if (chunk === undefined) { - if (end) stream.end(); - if (err) stream.destroy(); + if (err) { + stream.destroy(); + } + else if (end) { + stream.end(); + } callback(err); } else {