mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
tty: fix TypeError when stream is closed
Fixes: https://github.com/nodejs/node/issues/41330 PR-URL: https://github.com/nodejs/node/pull/43803 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
1 parent
f0d841fd7d
commit
be863b7a97
2 files changed
+10
-1
No files matched your search
+1
-1
@@ -73,7 +73,7 @@ ObjectSetPrototypeOf(ReadStream, net.Socket);
|
||||
|
||||
ReadStream.prototype.setRawMode = function(flag) {
|
||||
flag = !!flag;
|
||||
const err = this._handle.setRawMode(flag);
|
||||
const err = this._handle?.setRawMode(flag);
|
||||
if (err) {
|
||||
this.emit('error', errors.errnoException(err, 'setRawMode'));
|
||||
return this;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
|
||||
if (!process.stdin.isTTY) {
|
||||
common.skip('does not apply on non-TTY stdin');
|
||||
}
|
||||
|
||||
process.stdin.destroy();
|
||||
process.stdin.setRawMode(true);
|
||||
Reference in new issue
Block a user