From b5214a2f9fa374d7e7784904456152de7c2ceb82 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 10 Jun 2019 19:22:50 -0700 Subject: [PATCH] process/stdio: fix ref watching for readable stream. See: https://github.com/nodejs/node/pull/28153 --- lib/process/stdio.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/process/stdio.js b/lib/process/stdio.js index 172dbae..475c9de 100644 --- a/lib/process/stdio.js +++ b/lib/process/stdio.js @@ -30,8 +30,11 @@ class Readable extends stream.Readable { this._started = false; this.on('end', () => { - if (this._increments && --this._port._stdioRefs === 0) - this._port._stdioRef.unref(); + // See: https://github.com/nodejs/node/pull/28153 + if (this._started && this._increments) { + if (--this._port._stdioRefs === 0) + this._port._stdioRef.unref(); + } }); }