From 21bd6679ce150e193cacd4b1b6585928224f255a Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Thu, 20 Feb 2020 08:31:58 +0100 Subject: [PATCH] stream: fix finished typo https://github.com/nodejs/node/pull/31509 introduced a slight typo. Fortunately this typo does not have big impact due to `isWritableFinished()`. Fixes: https://github.com/nodejs/node/pull/31509#discussion_r381809355 PR-URL: https://github.com/nodejs/node/pull/31881 Fixes: https://github.com/nodejs/node/issues/31509 Reviewed-By: Matteo Collina Reviewed-By: Luigi Pinca --- lib/internal/streams/end-of-stream.js | 2 +- test/parallel/test-stream-finished.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/internal/streams/end-of-stream.js b/lib/internal/streams/end-of-stream.js index fcbca7d21a5350..88bdcb643dd201 100644 --- a/lib/internal/streams/end-of-stream.js +++ b/lib/internal/streams/end-of-stream.js @@ -62,7 +62,7 @@ function eos(stream, opts, callback) { }; let writableFinished = stream.writableFinished || - (rState && rState.finished); + (wState && wState.finished); const onfinish = () => { writable = false; writableFinished = true; diff --git a/test/parallel/test-stream-finished.js b/test/parallel/test-stream-finished.js index e866ba3d740fcc..c9c6bafd642e97 100644 --- a/test/parallel/test-stream-finished.js +++ b/test/parallel/test-stream-finished.js @@ -312,7 +312,6 @@ testClosed((opts) => new Writable({ write() {}, ...opts })); })); } - { const r = new Readable({ autoDestroy: false @@ -332,3 +331,14 @@ testClosed((opts) => new Writable({ write() {}, ...opts })); finished(rs, common.mustCall()); })); } + +{ + const d = new EE(); + d._writableState = {}; + d._writableState.finished = true; + finished(d, { readable: false, writable: true }, common.mustCall((err) => { + assert.strictEqual(err, undefined); + })); + d._writableState.errored = true; + d.emit('close'); +}