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

Promisifying prototype functions broken by v4 #67

Closed
Tapppi opened this issue Sep 25, 2018 · 1 comment
Closed

Promisifying prototype functions broken by v4 #67

Tapppi opened this issue Sep 25, 2018 · 1 comment

Comments

@Tapppi
Copy link

Tapppi commented Sep 25, 2018

v4 changed the returned function to an arrow function from a regular one. I cannot come up with a good reason to do that, since it breaks promisifying prototypes. The prototype function cannot be bound beforehand and the arrow function forces lexical this (which is undefined). util.promisify was our workaround, since this case doesn't need the extra options of pify..

E.g. there is no way to promisify node-redis multi queries now:

// Async multi exec
redis.Multi.prototype.execAsync = pify(redis.Multi.prototype.exec);

const client = new redis.createClient(...);

// Use
const cmds = [...];
const res = await client.multi(cmds).execAsync();

// Boom: Cannot read property 'queue' of undefined
@sindresorhus
Copy link
Owner

That is a regression indeed. I'm surprised we don't have a test for that.

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

No branches or pull requests

2 participants