Open sohhaofeng1989 opened 2 months ago
I'll need to debug a bit more, but for now I'll at least explain what should happen:
node-redis have 2 queues: waiting to be sent, and waiting for reply. When you execute a command it starts in the "waiting to be sent" queue, and after writing it to the socket (using nodejs socket.write
) it moves to the "waiting for reply" queue.
When a socket drops, the client rejects all "waiting for reply" commands since they might have been executed and might not, and then if the "offline queue" is enabled (see disabledOfflineQueue
), it'll keep the "waiting to be sent" queue, and executed them once a new connection established.
maybe socket.write
does not write the data immediately in some cases (?)
Description
Recently, we noticed that the
node-redis
client refuses to buffer redis commands upon encountering an ECONNRESET Error from the underlying socket connection. This is demonstrate-able by doing the following.node-redis
client thatconnect
s to a locally spun-up redis-serveriptables
command to simulate an ECONNRESET.error
Connection Events.It's noteworthy to point out 3 things
node-redis
does buffer redis commands for all other socket connection errors like ECONNREFUSED , EADDRNOTAVAIL etc. Only ECONNRESET doesn't trigger the offline queue buffering mechanismioredis
does buffer redis commands into its offline queue upon ECONNRESET.Node.js Version
20.8.1
Redis Server Version
7.0.7-alpine
Node Redis Version
4.6.12
Platform
Alpine Linux
Logs