Skip to content

wrap does not preserve Symbol.promisifyCustomArgs #19

@asztal

Description

@asztal

I was unsure whether this should be an issue with this module or async-listener, but I found an obscure bug in my code that only happened when one of my dependencies was loading async-listener (I think it was aws-xray-sdk-core).

Unfortunately the way shimmer monkey-patches fs.read means that it does not preserve customPromisifyArgs, which means that using util.promisify(fs.read)(...) returns simply the number bytesRead instead of the object { bytesRead, buffer } like it is meant to.

$ node -p 'Object.getOwnPropertySymbols(fs.read)'
[ Symbol(customPromisifyArgs) ]
$ node -r 'async-listener' -p 'Object.getOwnPropertySymbols(fs.read)'
[]

This can be quite tricky to find because it invalidates so many assumptions - I wasn't even aware that I had a dependency of a dependency of a dependency that was duck punching the fs module, so it took me much longer than I would like to admit to find that async-listener was the cause of my problems.

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