Skip to content
Permalink
Browse files

repl: use promise#finally

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 Oct 30, 2018
1 parent 9f8349c commit f866a0bcb9a7a8530a1249055afb195d72b196e3
Showing with 4 additions and 10 deletions.
  1. +4 −10 lib/repl.js
@@ -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();
});
}
}

0 comments on commit f866a0b

Please sign in to comment.
You can’t perform that action at this time.