From 67be60dcf6653916ed02403ea112cadcfa8d2719 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Mon, 23 Sep 2019 09:36:04 +0200 Subject: [PATCH] stream: remove ambiguous code --- lib/internal/streams/end-of-stream.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/internal/streams/end-of-stream.js b/lib/internal/streams/end-of-stream.js index 949ab638148d24..585a52ae2f2382 100644 --- a/lib/internal/streams/end-of-stream.js +++ b/lib/internal/streams/end-of-stream.js @@ -59,9 +59,9 @@ function eos(stream, opts, callback) { }; } - let readable = opts.readable || + const readable = opts.readable || (opts.readable !== false && isReadable(stream)); - let writable = opts.writable || + const writable = opts.writable || (opts.writable !== false && isWritable(stream)); const onlegacyfinish = () => { @@ -69,15 +69,13 @@ function eos(stream, opts, callback) { }; const onfinish = () => { - writable = false; writableFinished = true; - if (!readable) callback.call(stream); + if (!readable || readableEnded) callback.call(stream); }; const onend = () => { - readable = false; readableEnded = true; - if (!writable) callback.call(stream); + if (!writable || writableFinished) callback.call(stream); }; const onclose = () => {