From 4ab5f2bd361eab0450304a1f17c4a5e7b40a5ecc Mon Sep 17 00:00:00 2001 From: Elsaid Achraf <60660214+asaid-0@users.noreply.github.com> Date: Mon, 27 Dec 2021 04:33:08 +0200 Subject: [PATCH 1/2] lib: fix cannot read properties of null for setRawMode --- lib/tty.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tty.js b/lib/tty.js index 33e7c26f0291ed..219008b1086d74 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -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 && this._handle.setRawMode(flag); if (err) { this.emit('error', errors.errnoException(err, 'setRawMode')); return this; From 70294c585069cc665d04d66183953cc551ebe0d6 Mon Sep 17 00:00:00 2001 From: Elsaid Achraf <60660214+asaid-0@users.noreply.github.com> Date: Wed, 29 Dec 2021 07:47:17 +0200 Subject: [PATCH 2/2] add test-repl-stdin-push-null.js --- test/parallel/test-repl-stdin-push-null.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/parallel/test-repl-stdin-push-null.js diff --git a/test/parallel/test-repl-stdin-push-null.js b/test/parallel/test-repl-stdin-push-null.js new file mode 100644 index 00000000000000..a483c32c9af37a --- /dev/null +++ b/test/parallel/test-repl-stdin-push-null.js @@ -0,0 +1,12 @@ +'use strict'; +require('../common'); + +// This test ensures that the repl does not +// throw when using process.stdin stream to push null +// Refs: https://github.com/nodejs/node/issues/41330 + +const r = require('repl').start(); + +// Should not throw. +r.write('process.stdin.push(null)\n'); +r.write('.exit\n');