Skip to content

Commit

Permalink
repl: use promise#finally
Browse files Browse the repository at this point in the history
PR-URL: #23971
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
starkwang authored and MylesBorins committed Nov 29, 2018
1 parent 06844e8 commit e5177e9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,25 +374,19 @@ 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);
process.domain.exit();
return;
}
finishExecution(err);
}).finally(() => {
// Remove prioritized SIGINT listener if it was not called.
prioritizedSigintQueue.delete(sigintListener);
unpause();
});
}
}
Expand Down

0 comments on commit e5177e9

Please sign in to comment.