Skip to content

Commit

Permalink
fix: fix util.promisify implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed May 5, 2022
1 parent 5a6c80f commit 674dd27
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/runtime/node/util/_promisify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ function _promisify (fn: Function & { [customSymbol]?: Function}) {
}
return function (...args: any[]) {
return new Promise((resolve, reject) => {
// @ts-ignore
const value = fn.call(this, ...args, (err) => {
if (err) { return reject(err)}
})
resolve(value)
try {
// @ts-ignore
fn.call(this, ...args, (err, val) => {
if (err) { return reject(err)}
resolve(val)
})
} catch (err) {
reject(err)
}
})
}
}
Expand Down

0 comments on commit 674dd27

Please sign in to comment.