After a MOVING handoff, a client never becomes ready again on reconnect

Abierto
#3,705 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@nkaradzhov ya está trabajando en esto.

Desde el 4/12/2026.

  • #3707 de @nkaradzhov — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, typescript

Línea de trabajo

Start by reading #initiateSocket(), _ejectSocket(), and _insertSocket() and how EnterpriseMaintenanceManager moves a socket during a MOVING handoff. Reproduce with the RESP3 fake node used in enterprise-maintenance-manager.spec.ts, then check whether reconnect sends the handshake after the socket is inserted into the receiving client. Done means both automatic reconnect and destroy() followed by connect() become ready and ping() settles.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

After a MOVING handoff completes, any later reconnect hangs. This covers an automatic reconnect after the connection drops and a manual destroy() then connect(). The client opens a TCP connection to the endpoint but never sends the handshake, so it stays open and never becomes ready, and commands sent after the drop never settle.

Cause. #initiateSocket() builds each RedisSocket with an initiator closure bound to the client that created it. During a handoff, EnterpriseMaintenanceManager connects a duplicate() (the temporary client), then moves that client's RedisSocket into the real client via _ejectSocket()/_insertSocket() and destroys the temporary client. The swapped-in socket keeps the temporary client's initiator. On the next connect, the handshake is queued on the destroyed temporary client's queue and written through that client's #write(), so nothing reaches the new connection.

Reproduction (on master, with a minimal RESP3 fake node like the one in enterprise-maintenance-manager.spec.ts):

  1. createClient({ RESP: 3, maintNotifications: 'enabled', socket: { host, port: source, reconnectStrategy: 50 } }), then connect().
  2. Have the source send MOVING to the target, and wait for the handoff to complete. client.ping() works.
  3. Drop the connection on the target's side.

Expected: the client reconnects and client.ping() returns.
Actual: the client emits reconnecting and the target accepts a new TCP connection, but receives nothing. The client stays isOpen: true, isReady: false and client.ping() never settles.

The same happens if step 3 is client.destroy() followed by client.connect(): connect() never resolves.

As a control, the same drop with no handoff reconnects and becomes ready.

Possible fix: have _insertSocket() rebind the inserted socket's initiator to the receiving client, or build the replacement RedisSocket from the receiving client's own #initiateSocket() and move only the underlying net.Socket across.

Found while working on #3699.

Node.js Version

v22.22.0

Redis Server Version

N/A: reproduced against a minimal RESP3 fake node (as in enterprise-maintenance-manager.spec.ts), since the bug is in the client

Node Redis Version

master at ae5cfde4 (@redis/client 6.4.0)

Platform

Linux (WSL2)

Logs
# after the handoff completes, the target drops the connection (reconnectStrategy: 50)
isOpen=true isReady=false events=reconnecting   # ping() still pending after 1000ms
# after the handoff completes, destroy() then connect()
isOpen=true isReady=false events=end            # connect() never resolves
# control: same drop, no handoff
isOpen=true isReady=true                        # ping() returns OK
Lenguaje dominante
TypeScript
Estrellas
17.6k
Forks
2k
Merge medio
1 d 22 h
PR fusionados (30 d)
62

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de redis/node-redis

Todos los issues de redis/node-redis

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.