use mapped address when sentinel failover moved pubsub connections by elimelt · Pull Request #3190 · redis/node-redis

Description

Closes #3192

Fix small bug in sentinel's new nodeAddressMap option - namely - when sentinel failovers cause pub-sub connections to migrate to a new master, the address mapping should be applied.

This is 100% fixed by the patch (I patched with pnpm and got my client working), but I found it kind of difficult to write a good test that doesn't completely duplicate an existing test (e.g. pubsub - channel - with master change)

I'm also debating whether we want getMasterNode and similar to return the mapped address or not


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Medium Risk
Changes Sentinel failover reconfiguration logic for pub/sub connections; if the mapping is incorrect or incomplete it could cause pub/sub to reconnect to the wrong/unreachable node during master switches.

Overview
When Sentinel detects a new master, the pub/sub proxy now switches to the mapped node address (via getMappedNode(..., nodeAddressMap)) instead of using the raw Sentinel-reported host/port.

This fixes cases where nodeAddressMap is required (e.g., NAT/container networking) and failover previously moved pub/sub connections to an unmapped address.

Written by Cursor Bugbot for commit b7a34da. This will update automatically on new commits. Configure here.