Skip to content

Commit 5697cf3

Browse files
committed
tty: fix TypeError when stream is closed
Fixes: #41330
1 parent 3aec7da commit 5697cf3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/tty.js

Lines changed: 1 addition & 1 deletion
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;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
require('../common');
3+
4+
process.stdin.destroy();
5+
process.stdin.setRawMode(true);

0 commit comments

Comments
 (0)