diff --git a/lib/repl.js b/lib/repl.js index d71f636cd64dc8..f5ae5662368df2 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -374,18 +374,8 @@ function REPLServer(prompt, } promise.then((result) => { - // Remove prioritized SIGINT listener if it was not called. - // TODO(TimothyGu): Use Promise.prototype.finally when it becomes - // available. - prioritizedSigintQueue.delete(sigintListener); - finishExecution(undefined, result); - unpause(); }, (err) => { - // Remove prioritized SIGINT listener if it was not called. - prioritizedSigintQueue.delete(sigintListener); - - unpause(); if (err && process.domain) { debug('not recoverable, send to domain'); process.domain.emit('error', err); @@ -393,6 +383,10 @@ function REPLServer(prompt, return; } finishExecution(err); + }).finally(() => { + // Remove prioritized SIGINT listener if it was not called. + prioritizedSigintQueue.delete(sigintListener); + unpause(); }); } }