othiym23 / async-listener

polyfill version of the 0.11 version of the asyncListener API
https://www.npmjs.org/package/async-listener
BSD 2-Clause "Simplified" License
174 stars 52 forks source link

Fix bug activator function object missing properties (fs.realpath.native is undefined) #144

Closed geralfonso closed 2 years ago

geralfonso commented 2 years ago

Hey, This pr is aiming to solve this issue: #143 This sandbox replicate the issue: sandbox

Initially I was getting fs.realpath.native as undefined when using continuation-local-storage which is using async-listener as dependency. And continuation-local-storage in conjunction with fs-extra v10 are throwing this error. So in this particular case, I traced the issue to here. What's happening is that we are returning the wrapper without the original function object properties.

This shallow copy should be solve the problem by attaching the original function object properties to the wrapper function.

Qard commented 2 years ago

Why are you still using this? Node.js core has had AsyncLocalStorage for awhile now. If that's not an option, you could at least use cls-hooked which is at least a whole lot more up-to-date than this module which hasn't been maintained for years. 😅

geralfonso commented 2 years ago

Why are you still using this? Node.js core has had AsyncLocalStorage for awhile now. If that's not an option, you could at least use cls-hooked which is at least a whole lot more up-to-date than this module which hasn't been maintained for years. 😅

Oh Yeah, thanks the for the suggestion. You're right!