Skip to content

Commit 8b0a4af

Browse files
aduh95RafaelGSS
authored andcommitted
tty: fix TypeError when stream is closed
Fixes: #41330 PR-URL: #43803 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 1f23c17 commit 8b0a4af

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/tty.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ObjectSetPrototypeOf(ReadStream, net.Socket);
7272

7373
ReadStream.prototype.setRawMode = function(flag) {
7474
flag = !!flag;
75-
const err = this._handle.setRawMode(flag);
75+
const err = this._handle?.setRawMode(flag);
7676
if (err) {
7777
this.emit('error', errors.errnoException(err, 'setRawMode'));
7878
return this;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!process.stdin.isTTY) {
5+
common.skip('does not apply on non-TTY stdin');
6+
}
7+
8+
process.stdin.destroy();
9+
process.stdin.setRawMode(true);

0 commit comments

Comments
 (0)