You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
When using promisify(setTimeout) on the unwrapped, original, setTimeout function, it works just fine.
I understand this is because the original function has a util.promisify.custom field which contains the custom promisified version of it. But the wrapped one does not, and promisify can't automatically wrap a function with a callback as the 1st argument. I guess the solution would be to also create and wrap the util.promisify.custom field of setTimeout in async-listener/index.js (and maybe a more general solution, to other functions as well)
The text was updated successfully, but these errors were encountered:
Thanks for taking the time to investigate this issue.
Since Node.js version 8, Async Hooks have been part of Node core, which does more or less the same thing as this polyfill module. The util.promisify function was also added in Node 8. If you're using Node 8 or higher I would recommend using Async Hooks instead of this module.
I know this is not an solution to the problem you encountered and it probably is possible fix it in this module. But I don't personally have time to look into it. So I would recommend that you use Async Hooks instead if at all possible. You are of course also more than welcome to open a PR with a fix your self. Then I'm sure my self or one of the other maintainers will review it.
I have created a simple test (https://gist.github.com/ATGardner/7c34a90b01ed0bf513ccd6911b4372f3) which shows that when I try to use a promisified setTimeout call, it fails with
When using
promisify(setTimeout)
on the unwrapped, original, setTimeout function, it works just fine.I understand this is because the original function has a
util.promisify.custom
field which contains the custom promisified version of it. But the wrapped one does not, and promisify can't automatically wrap a function with a callback as the 1st argument. I guess the solution would be to also create and wrap theutil.promisify.custom
field of setTimeout in async-listener/index.js (and maybe a more general solution, to other functions as well)The text was updated successfully, but these errors were encountered: