Skip to content

Commit 10fcff7

Browse files
committed
fix pulseWhileDone promise handling
Small an oversight from the Bluebird -> Promise refactor. Fix #1695
1 parent 1faa5b3 commit 10fcff7

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

lib/utils/pulse-till-done.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@ module.exports = function (prefix, cb) {
2525
cb(er, ...args)
2626
}
2727
}
28-
module.exports.withPromise = pulseWhile
2928

30-
function pulseWhile (prefix, promise) {
29+
const pulseWhile = async (prefix, promise) => {
3130
if (!promise) {
3231
promise = prefix
3332
prefix = ''
3433
}
3534
pulseStart(prefix)
36-
return Promise.resolve(promise)
37-
.then(() => pulseStop())
38-
.catch(er => {
39-
pulseStop()
40-
throw er
41-
})
35+
try {
36+
return await promise
37+
} finally {
38+
pulseStop()
39+
}
4240
}
41+
module.exports.withPromise = pulseWhile

0 commit comments

Comments
 (0)