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 targos committed Nov 5, 2018
1 parent c7f471a commit e27f432
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 @@ -376,25 +376,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 e27f432

Please sign in to comment.