Skip to content

Using promisify on setTimeout causes it to fail #136

@ATGardner

Description

@ATGardner

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions