Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1ff8f68

Browse filesBrowse files
deokjinkimdanielleadams
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 d9593ce commit 1ff8f68
Copy full SHA for 1ff8f68

File tree

Expand file treeCollapse file tree

2 files changed

+19
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-1
lines changed
Open diff view settings
Collapse file

‎lib/readline.js‎

Copy file name to clipboardExpand all lines: lib/readline.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Interface.prototype.question = function(query, options, cb) {
146146
};
147147
options.signal.addEventListener('abort', onAbort, { once: true });
148148
const cleanup = () => {
149-
options.signal.removeEventListener(onAbort);
149+
options.signal.removeEventListener('abort', onAbort);
150150
};
151151
const originalCb = cb;
152152
cb = typeof cb === 'function' ? (answer) => {
Collapse file

‎test/parallel/test-readline-interface.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-readline-interface.js
+18Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.