Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap does not preserve Symbol.promisifyCustomArgs #19

Open
asztal opened this issue Dec 20, 2019 · 1 comment
Open

wrap does not preserve Symbol.promisifyCustomArgs #19

asztal opened this issue Dec 20, 2019 · 1 comment

Comments

@asztal
Copy link

asztal commented Dec 20, 2019

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.

@rochdev
Copy link

rochdev commented Oct 21, 2020

@othiym23 Is there a particular reason why shimmer does not copy properties and symbols from the original function? I'm willing to send a PR since we need this as well, but it's unclear if the omission was on purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants