Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions lib/Redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,18 +637,28 @@ class Redis extends Commander implements DataHandledable {
item.command.reject(err);
break;
case 2:
if (this.status !== "reconnecting") {
this.disconnect(true);
}
if (
this.condition?.select !== item.select &&
item.command.name !== "select"
) {
this.select(item.select);
const resendCommand = () => {
if (this.status !== "reconnecting") {
this.disconnect(true);
}
if (
this.condition?.select !== item.select &&
item.command.name !== "select"
) {
this.select(item.select);
}
// TODO
// @ts-expect-error
this.sendCommand(item.command);
};
if (typeof this.options.retryStrategy !== "function") {
return resendCommand();
}
// TODO
// @ts-expect-error
this.sendCommand(item.command);
const retryDelay = this.options.retryStrategy(++this.retryAttempts);
this.reconnectTimeout = setTimeout(() => {
this.reconnectTimeout = null;
resendCommand();
}, retryDelay);
break;
default:
item.command.reject(err);
Expand Down