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 <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
starkwang authored and MylesBorins committed Dec 3, 2018
1 parent 9f8349c commit f866a0b
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 f866a0b

Please sign in to comment.