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
RedisQueueDriver mutates EventEmitter prototype indirectly #84
Comments
Hey @vladi-dev ! Nice catch! |
Not exactly understand what is the solution you are proposing Meanwhile I opened a PR#85 to fix that, maybe could be a temporary fix Let me know if I can help with a better solution |
@paveltiunov please take a look at #89 |
Describe the bug
Configuration of redisClient is using the package
util-promisifyall
to promisify all redisClient methods (on redisClient.prototype) but it also promisifies redisClient protototype parent one level up the chain, which is EventEmitter's prototype since redisClient inherits EventEmitter class.Calling
promisifyAll
:https://github.com/statsbotco/cube.js/blob/50f1bbb7aac34ae7c4fd82a86ecee8506b17f4ea/packages/cubejs-query-orchestrator/orchestrator/RedisQueueDriver.js#L2-L7
redisClient
inheritsEventEmitter
:https://github.com/NodeRedis/node_redis/blob/12265a5079a133d2003bef9cdb0f2deee0251518/index.js#L189
Implementation of
utils-promisifyAll
takes methods of the input class and creates copies withAsync
suffix that return a promisified version of the original method.For me the problem arises when we are trying to use other libraries that use the concept of promisifying all.
For example
node-soap
:https://github.com/vpulim/node-soap/blob/0efafa219be15b0efac84c9228c161b8662f720f/lib/client.js#L22-L35
Here you can see promisification with
Bluebird.promisifyAll
of theClient
class which inheritsEventEmitter
but sinceEventEmitter
has been mutated it addsxxxAsync
methods toClient
's prototype and thenBluebird.promisifyAll
errors out with message:Cannot promisify an API that has normal methods
- http://bluebirdjs.com/docs/error-explanations.html#error-cannot-promisify-an-api-that-has-normal-methodsHere is the code that throws the error:
https://github.com/petkaantonov/bluebird/blob/17f69f3b0fa89a0b7a5cfb9a6546d1180a3610e0/src/promisify.js#L49-L65
So to solve that issue for me and possibly for other people that use
Bluebird.promisifyAll
I will open a PR to useBluebird
instead ofutil-promisifyall
if that is okay with you.I hope it is not an issue since
Bluebird
is already in some of sub-dependencies of this package.To Reproduce
Sandbox: https://codesandbox.io/embed/rmjmmnn73p
Or code:
Expected behavior
Expect that using the library does not modify prototype of the global class
EventEmitter
.Version:
0.7.0
The text was updated successfully, but these errors were encountered: