shimmer icon indicating copy to clipboard operation
shimmer copied to clipboard

`wrap` does not preserve Symbol.promisifyCustomArgs

Open asztal opened this issue 5 years ago • 1 comments
trafficstars

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.

asztal avatar Dec 20 '19 11:12 asztal

@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.

rochdev avatar Oct 21 '20 21:10 rochdev