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

getBuffer returns string when enableAutoPipelining is true #1228

Closed
adamnoakes opened this issue Nov 2, 2020 · 4 comments
Closed

getBuffer returns string when enableAutoPipelining is true #1228

adamnoakes opened this issue Nov 2, 2020 · 4 comments

Comments

@adamnoakes
Copy link
Contributor

Hi, firstly, thanks for releasing the new auto pipelining feature.

Whilst testing on my project, I noticed that getBuffer returns the result converted to string (rather than a Buffer) with enableAutoPipelining set to true. Is this expected/ a known limitation with the pipelining implementation?

@adamnoakes
Copy link
Contributor Author

Been looking into this a bit further and seems to be caused by *Buffer commands being created with Buffer omitted
https://github.com/luin/ioredis/blob/master/lib/commander.ts#L65-L71

commands.forEach(function (commandName) {
  Commander.prototype[commandName] = generateFunction(commandName, "utf8");
  Commander.prototype[commandName + "Buffer"] = generateFunction(
    commandName,
    null
  );
});

This commandName value is then used for calling the command again from the pipeline
https://github.com/luin/ioredis/blob/master/lib/commander.ts#L110-151

...
    // Create a new pipeline and make sure it's scheduled
    return executeWithAutoPipelining(this, commandName, args, callback);
  };

At which point the context that it's the Buffer variant of the command (and encoding is null) is lost.

@mcollina
Copy link
Contributor

mcollina commented Nov 9, 2020

cc @ShogunPanda

@ShogunPanda
Copy link
Contributor

I checked the PR. It LGTM!

@laverdet
Copy link

+1

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

No branches or pull requests

4 participants