Skip to content

Commit a79f37a

Browse files
deokjinkimtargos
authored andcommitted
lib: add missing type of removeEventListener in question
removeEventListener of signal is not working because event type is missed. PR-URL: #45676 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 1b92028 commit a79f37a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/readline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Interface.prototype.question = function question(query, options, cb) {
145145
};
146146
options.signal.addEventListener('abort', onAbort, { once: true });
147147
const cleanup = () => {
148-
options.signal.removeEventListener(onAbort);
148+
options.signal.removeEventListener('abort', onAbort);
149149
};
150150
const originalCb = cb;
151151
cb = typeof cb === 'function' ? (answer) => {

test/parallel/test-readline-interface.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,24 @@ for (let i = 0; i < 12; i++) {
921921
fi.emit('data', 'asdf\n');
922922
}
923923

924+
// Ensure that options.signal.removeEventListener was called
925+
{
926+
const ac = new AbortController();
927+
const signal = ac.signal;
928+
const [rli] = getInterface({ terminal });
929+
signal.removeEventListener = common.mustCall(
930+
(event, onAbortFn) => {
931+
assert.strictEqual(event, 'abort');
932+
assert.strictEqual(onAbortFn.name, 'onAbort');
933+
});
934+
935+
rli.question('hello?', { signal }, common.mustCall());
936+
937+
rli.write('bar\n');
938+
ac.abort();
939+
rli.close();
940+
}
941+
924942
// Sending a blank line
925943
{
926944
const [rli, fi] = getInterface({ terminal });

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy