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
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)
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.customfield 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.customfield of setTimeout in async-listener/index.js (and maybe a more general solution, to other functions as well)