Skip to content

Commit

Permalink
fixup! readline: fix pre-aborted signal question handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Linkgoron committed Mar 26, 2021
1 parent a39a0e7 commit f10ef73
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const {
StringPrototypeStartsWith,
StringPrototypeTrim,
Promise,
PromiseReject,
Symbol,
SymbolAsyncIterator,
SafeStringIterator,
Expand Down Expand Up @@ -400,11 +401,11 @@ Interface.prototype.question = function(query, options, cb) {
Interface.prototype.question[promisify.custom] = function(query, options) {
options = typeof options === 'object' && options !== null ? options : {};

return new Promise((resolve, reject) => {
if (options.signal?.aborted) {
throw new AbortError();
}
if (options.signal && options.signal.aborted) {
return PromiseReject(new AbortError());
}

return new Promise((resolve, reject) => {
this.question(query, options, resolve);
if (options.signal) {
options.signal.addEventListener('abort', () => {
Expand Down

0 comments on commit f10ef73

Please sign in to comment.