chore: improve existing error preservation in promisify (#16815)
This PR better preserves existing behavior in `deprecate.promisify()` in the cases where the promise fails. Previously, if a callback was only called with `data` instead of `err, data` and the promise was rejected, `data` would be populated with `err`, which could be confusing to users. This makes it such that `err` is called back on promise rejection if a callback is called with `err, data` a la Node.js.
This commit is contained in:
parent
4f8ebafa97
commit
9ebba76c03
2 changed files with 21 additions and 1 deletions
|
@ -89,7 +89,9 @@ const deprecate = {
|
|||
cb.length === 2 ? cb(null, res) : cb(res)
|
||||
})
|
||||
}, err => {
|
||||
process.nextTick(() => cb(err))
|
||||
process.nextTick(() => {
|
||||
cb.length === 2 ? cb(err) : cb()
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue