From 10fcff73a3381ea5e6dcb03888679ae4b501d2f0 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 20 Aug 2020 17:39:37 -0700 Subject: [PATCH] fix pulseWhileDone promise handling Small an oversight from the Bluebird -> Promise refactor. Fix #1695 --- lib/utils/pulse-till-done.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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