diff --git a/lib/utils/pulse-till-done.js b/lib/utils/pulse-till-done.js index 22080739aa11c..a533c064448da 100644 --- a/lib/utils/pulse-till-done.js +++ b/lib/utils/pulse-till-done.js @@ -25,18 +25,17 @@ module.exports = function (prefix, cb) { cb(er, ...args) } } -module.exports.withPromise = pulseWhile -function pulseWhile (prefix, promise) { +const pulseWhile = async (prefix, promise) => { if (!promise) { promise = prefix prefix = '' } pulseStart(prefix) - return Promise.resolve(promise) - .then(() => pulseStop()) - .catch(er => { - pulseStop() - throw er - }) + try { + return await promise + } finally { + pulseStop() + } } +module.exports.withPromise = pulseWhile