From a8a86387fa4a8bb2c0e058c5c16f3fa666f15fe7 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 3 Jul 2021 22:10:21 +0200 Subject: [PATCH] tty: enable buffering HWM was set to 0 which would cause e.g. stdout.write(...) to always return false. Refs: https://github.com/nodejs/node/pull/39246 PR-URL: https://github.com/nodejs/node/pull/39253 Reviewed-By: Anna Henningsen Reviewed-By: Benjamin Gruenbaum --- lib/tty.js | 4 ++-- test/parallel/test-stdout-stderr-write.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-stdout-stderr-write.js diff --git a/lib/tty.js b/lib/tty.js index d9c576b5fd6..33e7c26f029 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -57,7 +57,7 @@ function ReadStream(fd, options) { } net.Socket.call(this, { - highWaterMark: 0, + readableHighWaterMark: 0, handle: tty, manualStart: true, ...options @@ -94,7 +94,7 @@ function WriteStream(fd) { } net.Socket.call(this, { - highWaterMark: 0, + readableHighWaterMark: 0, handle: tty, manualStart: true }); diff --git a/test/parallel/test-stdout-stderr-write.js b/test/parallel/test-stdout-stderr-write.js new file mode 100644 index 00000000000..803fc70536b --- /dev/null +++ b/test/parallel/test-stdout-stderr-write.js @@ -0,0 +1,8 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); + +// https://github.com/nodejs/node/pull/39246 +assert.strictEqual(process.stderr.write('asd'), true); +assert.strictEqual(process.stdout.write('asd'), true);