Skip to content

Commit be863b7

Browse files
aduh95juanarbol
authored andcommitted
tty: fix TypeError when stream is closed
Fixes: #41330 PR-URL: #43803 Reviewed-By: Joyee Cheung <[email protected]>
1 parent f0d841f commit be863b7

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
@@ -73,7 +73,7 @@ ObjectSetPrototypeOf(ReadStream, net.Socket);
7373

7474
ReadStream.prototype.setRawMode = function(flag) {
7575
flag = !!flag;
76-
const err = this._handle.setRawMode(flag);
76+
const err = this._handle?.setRawMode(flag);
7777
if (err) {
7878
this.emit('error', errors.errnoException(err, 'setRawMode'));
7979
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)