Skip to content

Commit

Permalink
fix: Fix commands not resend on reconnect in edge cases (#1720)
Browse files Browse the repository at this point in the history
Closes #1718
  • Loading branch information
luin committed Feb 12, 2023
1 parent 0922c48 commit fe52ff1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/redis/event_handler.ts
Expand Up @@ -155,19 +155,25 @@ function abortTransactionFragments(commandQueue: Deque<CommandItem>) {

export function closeHandler(self) {
return function () {
const prevStatus = self.status;
self.setStatus("close");

if (!self.prevCondition) {
self.prevCondition = self.condition;
}
if (self.commandQueue.length) {
abortIncompletePipelines(self.commandQueue);
self.prevCommandQueue = self.commandQueue;
}
if (self.offlineQueue.length) {
abortTransactionFragments(self.offlineQueue);
}

if (prevStatus === "ready") {
if (!self.prevCondition) {
self.prevCondition = self.condition;
}
if (self.commandQueue.length) {
self.prevCommandQueue = self.commandQueue;
}
}

if (self.manuallyClosing) {
self.manuallyClosing = false;
debug("skip reconnecting since the connection is manually closed.");
Expand Down

0 comments on commit fe52ff1

Please sign in to comment.