Skip to content

Commit c834be0

Browse files
addaleaxjasnell
authored andcommitted
Revert "tty: make _read throw ERR_TTY_WRITABLE_NOT_READABLE"
This reverts commit 91eec00. Refs: #21654 Refs: #21203 PR-URL: #23053 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 0e33493 commit c834be0

File tree

5 files changed

+8
-38
lines changed

5 files changed

+8
-38
lines changed

doc/api/errors.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1708,12 +1708,6 @@ A `Transform` stream finished with data still in the write buffer.
17081708

17091709
The initialization of a TTY failed due to a system error.
17101710

1711-
<a id="ERR_TTY_WRITABLE_NOT_READABLE"></a>
1712-
### ERR_TTY_WRITABLE_NOT_READABLE
1713-
1714-
This `Error` is thrown when a read is attempted on a TTY `WriteStream`,
1715-
such as `process.stdout.on('data')`.
1716-
17171711
<a id="ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET"></a>
17181712
### ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET
17191713

@@ -2068,6 +2062,13 @@ instance.setEncoding('utf8');
20682062
An attempt has been made to create a string larger than the maximum allowed
20692063
size.
20702064

2065+
<a id="ERR_TTY_WRITABLE_NOT_READABLE"></a>
2066+
#### ERR_TTY_WRITABLE_NOT_READABLE
2067+
2068+
This `Error` is thrown when a read is attempted on a TTY `WriteStream`,
2069+
such as `process.stdout.on('data')`.
2070+
2071+
20712072
[`--force-fips`]: cli.html#cli_force_fips
20722073
[`'uncaughtException'`]: process.html#process_event_uncaughtexception
20732074
[`child_process`]: child_process.html

lib/internal/errors.js

-3
Original file line numberDiff line numberDiff line change
@@ -844,9 +844,6 @@ E('ERR_TRANSFORM_ALREADY_TRANSFORMING',
844844
E('ERR_TRANSFORM_WITH_LENGTH_0',
845845
'Calling transform done when writableState.length != 0', Error);
846846
E('ERR_TTY_INIT_FAILED', 'TTY initialization failed', SystemError);
847-
E('ERR_TTY_WRITABLE_NOT_READABLE',
848-
'The Writable side of a TTY is not Readable',
849-
Error);
850847
E('ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET',
851848
'`process.setupUncaughtExceptionCapture()` was called while a capture ' +
852849
'callback was already active',

lib/tty.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ const { inherits, _extend } = require('util');
2525
const net = require('net');
2626
const { TTY, isTTY } = internalBinding('tty_wrap');
2727
const errors = require('internal/errors');
28-
const {
29-
ERR_INVALID_FD,
30-
ERR_TTY_INIT_FAILED,
31-
ERR_TTY_WRITABLE_NOT_READABLE
32-
} = errors.codes;
28+
const { ERR_INVALID_FD, ERR_TTY_INIT_FAILED } = errors.codes;
3329
const { getColorDepth } = require('internal/tty');
3430

3531
// Lazy loaded for startup performance.
@@ -131,13 +127,6 @@ WriteStream.prototype._refreshSize = function() {
131127
}
132128
};
133129

134-
// A WriteStream is not readable from, so _read become a no-op.
135-
// this method could still be called because net.Socket()
136-
// is a duplex
137-
WriteStream.prototype._read = function() {
138-
this.destroy(new ERR_TTY_WRITABLE_NOT_READABLE());
139-
};
140-
141130
// Backwards-compat
142131
WriteStream.prototype.cursorTo = function(x, y) {
143132
if (readline === undefined) readline = require('readline');

test/pseudo-tty/test-tty-write-stream-resume-crash.js

-17
This file was deleted.

test/pseudo-tty/test-tty-write-stream-resume-crash.out

Whitespace-only changes.

0 commit comments

Comments
 (0)