mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -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
1f23c17ae0
commit
8b0a4afcae
2 files changed
+10
-1
No files matched your search
+1
-1
@@ -72,7 +72,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