Commit 653ebef
committed
feat(redis): add reconnectOnError for READONLY / LOADING reply errors
During an ElastiCache role swap or node-type change, the TCP/TLS
connection stays open but the server starts answering with READONLY
(the client is talking to a node that became a replica) or LOADING
(node still loading data from disk). Without an explicit hook, these
errors surface to caller code as ReplyError instances — every write
op on the affected connection fails until the cluster cuts over.
Returning 2 from reconnectOnError tells ioredis to tear down the
connection, reconnect, and re-issue the failed command. After
reconnect, DNS / SG state routes the new socket to a writable node.
The shared createRedisClient helper picks this up automatically.
defaultReconnectOnError is exported for direct ioredis call sites
that bypass createRedisClient.1 parent 6cdd881 commit 653ebef
2 files changed
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
6 | 25 | | |
7 | 26 | | |
8 | 27 | | |
9 | 28 | | |
10 | 29 | | |
11 | 30 | | |
| 31 | + | |
12 | 32 | | |
13 | 33 | | |
14 | 34 | | |
| |||
0 commit comments