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

Đang mở
#3,705 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@nkaradzhov đang làm issue này rồi.

Từ ngày 4/12/2026.

  • #3707 của @nkaradzhov — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
backend, networking

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
TypeScript
Star
17.6k
Fork
2k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
62

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của redis/node-redis

Tất cả issue của redis/node-redis

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.