GeezerVison is showing github.com — lib: add missing type of removeEventListener in question · nodejs/node@1ff8f68
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/readline.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -146,7 +146,7 @@ Interface.prototype.question = function(query, options, cb) { |
146 | 146 | }; |
147 | 147 | options.signal.addEventListener('abort', onAbort, { once: true }); |
148 | 148 | const cleanup = () => { |
149 | | - options.signal.removeEventListener(onAbort); |
| 149 | + options.signal.removeEventListener('abort', onAbort); |
150 | 150 | }; |
151 | 151 | const originalCb = cb; |
152 | 152 | cb = typeof cb === 'function' ? (answer) => { |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-readline-interface.js +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -921,6 +921,24 @@ for (let i = 0; i < 12; i++) { |
921 | 921 | fi.emit('data', 'asdf\n'); |
922 | 922 | } |
923 | 923 |
|
| 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 | + |
924 | 942 | // Sending a blank line |
925 | 943 | { |
926 | 944 | const [rli, fi] = getInterface({ terminal }); |
|