Skip to content

Commit fe52ff1

Browse files
authored
fix: Fix commands not resend on reconnect in edge cases (#1720)
Closes #1718
1 parent 0922c48 commit fe52ff1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Diff for: lib/redis/event_handler.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,25 @@ function abortTransactionFragments(commandQueue: Deque<CommandItem>) {
155155

156156
export function closeHandler(self) {
157157
return function () {
158+
const prevStatus = self.status;
158159
self.setStatus("close");
159160

160-
if (!self.prevCondition) {
161-
self.prevCondition = self.condition;
162-
}
163161
if (self.commandQueue.length) {
164162
abortIncompletePipelines(self.commandQueue);
165-
self.prevCommandQueue = self.commandQueue;
166163
}
167164
if (self.offlineQueue.length) {
168165
abortTransactionFragments(self.offlineQueue);
169166
}
170167

168+
if (prevStatus === "ready") {
169+
if (!self.prevCondition) {
170+
self.prevCondition = self.condition;
171+
}
172+
if (self.commandQueue.length) {
173+
self.prevCommandQueue = self.commandQueue;
174+
}
175+
}
176+
171177
if (self.manuallyClosing) {
172178
self.manuallyClosing = false;
173179
debug("skip reconnecting since the connection is manually closed.");

0 commit comments

Comments
 (0)