From c7405fe9cb91124d966235467d6a9148e6bc9bd5 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 24 Sep 2018 11:15:37 +0200 Subject: [PATCH] Revert "tty: make _read throw ERR_TTY_WRITABLE_NOT_READABLE" This reverts commit 91eec00ca20a54b1dc010cfc2fb34bc2f39eab6b. Refs: https://github.com/nodejs/node/pull/21654 Refs: https://github.com/nodejs/node/issues/21203 PR-URL: https://github.com/nodejs/node/pull/23053 Reviewed-By: James M Snell --- doc/api/errors.md | 13 +++++++------ lib/internal/errors.js | 3 --- lib/tty.js | 13 +------------ .../test-tty-write-stream-resume-crash.js | 17 ----------------- .../test-tty-write-stream-resume-crash.out | 0 5 files changed, 8 insertions(+), 38 deletions(-) delete mode 100644 test/pseudo-tty/test-tty-write-stream-resume-crash.js delete mode 100644 test/pseudo-tty/test-tty-write-stream-resume-crash.out diff --git a/doc/api/errors.md b/doc/api/errors.md index f9005c3bb19..1cdd1d0f20a 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1708,12 +1708,6 @@ A `Transform` stream finished with data still in the write buffer. The initialization of a TTY failed due to a system error. - -### ERR_TTY_WRITABLE_NOT_READABLE - -This `Error` is thrown when a read is attempted on a TTY `WriteStream`, -such as `process.stdout.on('data')`. - ### ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET @@ -2068,6 +2062,13 @@ instance.setEncoding('utf8'); An attempt has been made to create a string larger than the maximum allowed size. + +#### ERR_TTY_WRITABLE_NOT_READABLE + +This `Error` is thrown when a read is attempted on a TTY `WriteStream`, +such as `process.stdout.on('data')`. + + [`--force-fips`]: cli.html#cli_force_fips [`'uncaughtException'`]: process.html#process_event_uncaughtexception [`child_process`]: child_process.html diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 19638b83eee..b9a1282c6e6 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -844,9 +844,6 @@ E('ERR_TRANSFORM_ALREADY_TRANSFORMING', E('ERR_TRANSFORM_WITH_LENGTH_0', 'Calling transform done when writableState.length != 0', Error); E('ERR_TTY_INIT_FAILED', 'TTY initialization failed', SystemError); -E('ERR_TTY_WRITABLE_NOT_READABLE', - 'The Writable side of a TTY is not Readable', - Error); E('ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET', '`process.setupUncaughtExceptionCapture()` was called while a capture ' + 'callback was already active', diff --git a/lib/tty.js b/lib/tty.js index 83e00df1106..62945a78eb1 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -25,11 +25,7 @@ const { inherits, _extend } = require('util'); const net = require('net'); const { TTY, isTTY } = internalBinding('tty_wrap'); const errors = require('internal/errors'); -const { - ERR_INVALID_FD, - ERR_TTY_INIT_FAILED, - ERR_TTY_WRITABLE_NOT_READABLE -} = errors.codes; +const { ERR_INVALID_FD, ERR_TTY_INIT_FAILED } = errors.codes; const { getColorDepth } = require('internal/tty'); // Lazy loaded for startup performance. @@ -131,13 +127,6 @@ WriteStream.prototype._refreshSize = function() { } }; -// A WriteStream is not readable from, so _read become a no-op. -// this method could still be called because net.Socket() -// is a duplex -WriteStream.prototype._read = function() { - this.destroy(new ERR_TTY_WRITABLE_NOT_READABLE()); -}; - // Backwards-compat WriteStream.prototype.cursorTo = function(x, y) { if (readline === undefined) readline = require('readline'); diff --git a/test/pseudo-tty/test-tty-write-stream-resume-crash.js b/test/pseudo-tty/test-tty-write-stream-resume-crash.js deleted file mode 100644 index 12ec1df45ad..00000000000 --- a/test/pseudo-tty/test-tty-write-stream-resume-crash.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -const common = require('../common'); -const { WriteStream } = require('tty'); -const fd = common.getTTYfd(); - -// Calling resume on a tty.WriteStream should be a no-op -// Ref: https://github.com/nodejs/node/issues/21203 - -const stream = new WriteStream(fd); -stream.resume(); - -stream.on('error', common.expectsError({ - code: 'ERR_TTY_WRITABLE_NOT_READABLE', - type: Error, - message: 'The Writable side of a TTY is not Readable' -})); diff --git a/test/pseudo-tty/test-tty-write-stream-resume-crash.out b/test/pseudo-tty/test-tty-write-stream-resume-crash.out deleted file mode 100644 index e69de29bb2d..00000000000