Skip to content

Connection hangs after temporarily lost connection from redis #2632

Closed
@gpad

Description

@gpad

Description

If I open a connection like this:

const conn = await createClient(options)
      .on("connect", () => {
        console.log("redis connect")
      })
      .on("ready", () => {
        console.log("redis ready")
      })
      .on("end", () => {
        console.log("redis end")
      })
      .on("error", async (error) => {
        console.log("redis error", error)
      })
      .on("reconnecting", () => {
        console.log("redis reconnecting")
      })
      .connect()

await conn.set('key', 'value');

I see this logs:

>> redis connect 
>> redis ready 

thank I can use the connection without any issue.

If I restart Redis to simulate a connection lost, I see an automatic reconnection with the following logs:

>> redis error SocketClosedUnexpectedlyError: Socket closed unexpectedly
>> redis reconnecting
>> redis connect

First of all, I never see ready and then if I try to use the connection await conn.set('key', 'value'); the call remain blocked indefinitely.

Node.js Version

v16.13.0 + v18.17.1

Redis Server Version

6.2.6

Node Redis Version

4.6.10

Platform

linux / docker

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions