Skip to content

Promisifying prototype functions broken by v4 #67

@Tapppi

Description

@Tapppi

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions