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:
Antoine du Hamel authored and Juan José Arboleda committed 2022-10-11 14:45:19 -05:00
1 parent f0d841fd7d
commit be863b7a97
2 files changed
+10 -1

No files matched your search

+1 -1
View File
@@ -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);