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

"TypeError: str.charCodeAt is not a function" when using Buffers as keys in cluster-mode #593

Closed
ghost opened this issue Mar 5, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 5, 2018

Though using binary data as keys (represented as a "Buffer" in JavaScript) works as expected in non-cluster mode, it breaks when you are running Redis in cluster mode:

 TypeError: str.charCodeAt is not a function
     at toUTF8Array (/group-sign/server/node_modules/cluster-key-slot/lib/index.js:93:16)
     at generate (/group-sign/server/node_modules/cluster-key-slot/lib/index.js:133:14)
     at Command.getSlot (/group-sign/server/node_modules/ioredis/lib/command.js:88:19)
     at Cluster.sendCommand (/group-sign/server/node_modules/ioredis/lib/cluster/index.js:440:47)
     at Cluster.set (/group-sign/server/node_modules/ioredis/lib/commander.js:131:17)
    ...

Looks like in the call to the the cluster-key-slot library, the key is expected to be a String, not a Buffer:
https://github.com/luin/ioredis/blob/master/lib/command.js#L90

In non-cluster mode, the code is not executed as there is no need to compute the slot. I assume that is why it works there.

(As a workaround, I have switched to Strings for the keys.)

@stale
Copy link

stale bot commented Apr 4, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed.

@stale stale bot added the wontfix label Apr 4, 2018
@stale stale bot closed this as completed Apr 11, 2018
@tinder-xhao
Copy link

Is there any update about this issue? I'm encountering the same problem here

@tuananh
Copy link
Contributor

tuananh commented Feb 12, 2019

similar to #637

@philipp-classen
Copy link

@tuananh You are right, it is a duplicate of the new #637 ticket.

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

3 participants