-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix creation of cluster client again #2870
Conversation
# Conflicts: # packages/client/lib/cluster/cluster-slots.ts
FYI @leibale |
Sorry about it.. I'm not sure what happened, but I'll need to make sure that we did not lose more work.. |
Thanks for taking care 👍 |
@leibale I worked on this with @soccermax. We had an issue recently and we realized that the our reconnecting handler is not called even when the reconnectStrategy is used and reconnect attempts are happening. From local debugging, it looks to me like the socket is emitting both "error" and "reconnecting" const retryIn = this.#shouldReconnect(retries++, err as Error);
if (typeof retryIn !== 'number') {
throw retryIn;
}
this.emit('error', err);
await promiseTimeout(retryIn);
this.emit('reconnecting'); These events are forwarded to the client .on('error', err => {
this.emit('error', err);
if (this.#socket.isOpen && !this.#options?.disableOfflineQueue) {
this.#queue.flushWaitingForReply(err);
} else {
this.#queue.flushAll(err);
}
})
//...
.on('reconnecting', () => this.emit('reconnecting')) but only the error is forwarded to the cluster interface async #createClient(
node: ShardNode<M, F, S>,
readonly = node.readonly
) {
const client = new this.#Client(
this.#clientOptionsDefaults({
socket: this.#getNodeAddress(node.address) ?? {
host: node.host,
port: node.port
},
readonly
})
);
client.on('error', err => this.#emit('error', err));
await client.connect();
return client;
} Maybe I'm misunderstanding the client vs cluster usage intentions. I would have assumed that it makes sense to forward either event. Our code is something like if (...) { //env has cluster credentials
client = redis.createCluster(...)
} else if () { // env has client credentials
client = redis.createClient(...)
} else { ... }
client.on("error", (err) => { ... });
client.on("reconnecting", () => { ... }); Hope you can help us understand this better. Sorry for the verbosity, but this is most easily explained directly with code :-) |
Description
In the following PR #2783 we fixed the issue #2721. That fix got removed from master and therefore also in the current releases. Could you please include this fix again and release a new version? Thank you very much 👍
Checklist
npm test
pass with this change (including linting)?