redis / node-redis

Redis Node.js client
https://redis.js.org/
MIT License
16.95k stars 1.89k forks source link

fix createCluster - copy `options.defaults.socket` before modifying it #2783

Closed soccermax closed 4 months ago

soccermax commented 4 months ago

Description

Describe your pull request here

https://github.com/redis/node-redis/pull/2373 introduced a bug into the creation of cluster clients. The issue is that provided options for creating a socket are changed. The function clientOptionsDefaults in cluster-slots.ts is called twice once with disableReconnect false and the second call is the real call for creating clients but the function clientOptionsDefaults is overriding this.#options.defaults.socket at line 289 because result.socket is the same reference as this.#options.defaults.socket

fix https://github.com/redis/node-redis/issues/2721


Checklist

soccermax commented 4 months ago

Good catch! I'm working on releasing it right now.. :)

nice, thanks for the fast reaction