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

Socket options object is modified #2851

Open
adoeppner opened this issue Oct 14, 2024 · 0 comments
Open

Socket options object is modified #2851

adoeppner opened this issue Oct 14, 2024 · 0 comments
Labels

Comments

@adoeppner
Copy link

adoeppner commented Oct 14, 2024

Description

We have a service that is connected to multiple Redis servers. We noticed that after a connection loss, some of the connections suddenly started throwing weird auth errors.

WRONGPASS invalid username-password pair or user is disabled.

After a bit of digging we discovered that we have some default options that we use for each of our redis connections, and this object reference is overwritten by each redis client we instantiate.

A simple setup to run into the problem immediately looks like this, but if you connect to redis directly after instantiating the redis client, you won't notice the error until the client tries to reconnect.

const options = {
    socket: {
        reconnectStrategy: () => 10000
    }
}

const client1 = createClient({ url: "redis://:server1pass@localhost:2345", ...options })
const client2 = createClient({ url: "redis://:server2pass@localhost:2346", ...options })

client1.on("error", (err) => logger.error("Redis client1 error:", err))
client2.on("error", (err) => logger.error("Redis client2 error:", err))

await client1.connect()
await client2.connect()

You could argue this is done by design but it feels a bit strange and cost us a few hours of debugging. Code which leads to this is here:

https://github.com/redis/node-redis/blob/master/packages/client/lib/client/index.ts#L248

Node.js Version

v20.15.1

Redis Server Version

7.2.5

Node Redis Version

4.6.7

Platform

any

Logs

No response

@adoeppner adoeppner added the Bug label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant