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

Aperta
#3,705 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@nkaradzhov ci sta già lavorando.

Dal 4/12/2026.

  • #3707 di @nkaradzhov — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
TypeScript
Stelle
17.6k
Fork
2k
Merge medio
1g 22h
PR unite (30g)
62

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di redis/node-redis

Tutte le issue di redis/node-redis

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.