Skip to content

Conversation

@nfriedly
Copy link
Member

@nfriedly nfriedly commented Nov 18, 2025

This adds a sendCommandCluster option as an alternative to sendCommand.

It can be set to a function that is passed an object with the key and isReadOnly value, in addition to the command. This provides everything that node-redis needs in cluster mode, and is expandable with new fields if necessary to support other libraries in cluster mode.

Additionally I tweaked the internals to always pass this information along - previously the key would be lost when loading the script, so it could inadvertenly get sent to the wrong redis server.

Fixes #222
Fixes #207
Fixes #208

Tests are failing on my machine, even without these changes. Jest seems to think everything is commonjs and then chokes when it hits the first import or export statement. I'm putting this up as a draft to see if it works in CI.

Edit: it passed on CI, so I think there's just something wrong with my machine. Still, please give it a bit of extra scrutiny.

This adds a `sendCommandCluster` option as an alternative to `sendCommand`.

It can be set to a function that is passed an object with the key and isReadOnly value, in addition to the command. This provides everything that node-redis needs in cluster mode, and is expandable with new fields if necessary to support other libraries in cluster mode.

Additionally I tweaked the internals to always pass this information along - previously the key would be lost when loading the script, so it could inadvertenly get sent to the wrong redis server.

Fixes #222
Fixes #207
Fixes #208
Copy link
Collaborator

@mt-ks mt-ks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!, Tested manually on local.

Image

Copy link
Member

@gamemaker1 gamemaker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you so much @nfriedly!

Thanks @mt-ks for testing it manually - perhaps we can turn that into an external test like we have in express-rate-limit? We could use the docker configuration from your comment here.

@nfriedly nfriedly marked this pull request as ready for review November 19, 2025 22:54
@nfriedly
Copy link
Member Author

Cool, thanks for the reviews, I'm going to go ahead and ship this. But, additional tests are a good idea.

@nfriedly nfriedly merged commit 0ab9415 into main Nov 19, 2025
16 checks passed
@nfriedly nfriedly deleted the cluster-send-command branch November 19, 2025 22:55
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

Successfully merging this pull request may close these issues.

Library is problematic with multi-slot cluster configuration RedisStore: args.length: Cannot read properties of undefined (reading length).

4 participants