From 8c606851056a1bb38abdcf7ab15df8ae35ba0cf9 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Wed, 9 Oct 2019 19:52:32 +0200 Subject: [PATCH] Revert "stream: remove ambiguous code" This reverts commit ce62e963a13044817b43b7a7c6ef794eaa5ae905. PR-URL: https://github.com/nodejs/node/pull/29717 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Rich Trott Reviewed-By: Beth Griggs --- lib/internal/streams/end-of-stream.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/internal/streams/end-of-stream.js b/lib/internal/streams/end-of-stream.js index 585a52ae2f2382..949ab638148d24 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) { }; } - const readable = opts.readable || + let readable = opts.readable || (opts.readable !== false && isReadable(stream)); - const writable = opts.writable || + let writable = opts.writable || (opts.writable !== false && isWritable(stream)); const onlegacyfinish = () => { @@ -69,13 +69,15 @@ function eos(stream, opts, callback) { }; const onfinish = () => { + writable = false; writableFinished = true; - if (!readable || readableEnded) callback.call(stream); + if (!readable) callback.call(stream); }; const onend = () => { + readable = false; readableEnded = true; - if (!writable || writableFinished) callback.call(stream); + if (!writable) callback.call(stream); }; const onclose = () => {