diff --git a/lib/readline.js b/lib/readline.js index 6a1ed150d72cd2..60864f40afdbc1 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -1039,9 +1039,6 @@ function emitKeypressEvents(stream, iface) { } else { stream.on('newListener', onNewListener); } - if (iface) { - iface.once('close', () => { stream.removeListener('data', onData); }); - } } /** diff --git a/test/parallel/test-readline-set-raw-mode.js b/test/parallel/test-readline-set-raw-mode.js index ddffd131d0baff..db42a5a9495a9e 100644 --- a/test/parallel/test-readline-set-raw-mode.js +++ b/test/parallel/test-readline-set-raw-mode.js @@ -74,8 +74,6 @@ assert(!rawModeCalled); assert(resumeCalled); assert(!pauseCalled); -// One data listener for the keypress events. -assert.strictEqual(stream.listeners('data').length, 1); // close() should call setRawMode(false) expectedRawMode = false; @@ -88,5 +86,5 @@ assert(!resumeCalled); assert(pauseCalled); assert.deepStrictEqual(stream.listeners('keypress'), []); -// Data listener is removed once interface is closed. -assert.strictEqual(stream.listeners('data').length, 0); +// one data listener for the keypress events. +assert.strictEqual(stream.listeners('data').length, 1);