Skip to content

Fix/subscriber connection dying#2080

Open
jracabado wants to merge 2 commits intoredis:mainfrom
jracabado:fix/subscriber-connection-dying
Open

Fix/subscriber connection dying#2080
jracabado wants to merge 2 commits intoredis:mainfrom
jracabado:fix/subscriber-connection-dying

Conversation

@jracabado
Copy link
Copy Markdown

@jracabado jracabado commented Feb 23, 2026

This PR ensures the Cluster is refreshed when a Cluster Subscriber connection (.psubscribe, .subscribe) dies.

Previously when a subscriber connection is killed we only selected a new node from the cluster connection pool.

If the client instance is only keeping Cluster Subscriber connections this means the Cluster is never refreshed. The implication is that if the Cluster is changing and new nodes are being added, the connection pool will only contain non-available nodes and the subscription won't be able to be resumed.

This is a state that can be avoided when the client instance also maintains other non-subscriber connections, the error handling on these will try to refresh the cluster. Given there are still live nodes in the connection pool it will be able to refresh the connection pool: https://github.com/redis/ioredis/blob/main/lib/cluster/index.ts#L549

@jit-ci
Copy link
Copy Markdown

jit-ci bot commented Feb 23, 2026

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@PavelPashov
Copy link
Copy Markdown
Contributor

@jracabado, thanks for the PR, I’ll take a look when I get a chance.

@PavelPashov
Copy link
Copy Markdown
Contributor

run sharded pub sub tests

@uglide
Copy link
Copy Markdown
Contributor

uglide commented Feb 24, 2026

Testcase Errors Failures Skipped Total
Root Suite 0 0 0 0
Sharded Pub/Sub E2E 0 0 0 0
Single Subscriber 0 0 0 3
Multiple Subscribers 0 0 0 2

---- Details for maintainers

@headlessme
Copy link
Copy Markdown
Contributor

@PavelPashov we've had this failure in production, would be great to see a fix merged

@PavelPashov
Copy link
Copy Markdown
Contributor

@jracabado is it possible to provide a test that validates the correct behavior or minimal reproducible example that demonstrates the expected vs. actual behavior?

Also, if I’m understanding correctly, this only happens with standard (p)subscribe in Cluster mode. As a temporary workaround, would setting lazyConnect: false inside redisOptions help?

const cluster = new Cluster(startupNodes, {
  redisOptions: { lazyConnect: false },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants