Skip to content

feat: RedisOptions.familyFallback - #46

Merged
mcollina merged 4 commits into
valkey-io:mainfrom
bauchdj:main
Apr 3, 2026
Merged

feat: RedisOptions.familyFallback#46
mcollina merged 4 commits into
valkey-io:mainfrom
bauchdj:main

Conversation

@bauchdj

@bauchdj bauchdj commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Issue: #38

Added simple fallback option. On reconnect it will alternate between family 4 and 6.

The unit tests include:

  • failing to connect to host that does not exist
  • verifying family 0 results in an IPv6 connection
  • verifying after connection failure, it continues to use family 0 and does not alternate already
  • verify that options.familyFallback works (both with and without an initial family value provided)

Signed-off-by: David Bauch <jamesbauch@gmail.com>

@mcollina mcollina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please document this new option?

Good work!

@bauchdj

bauchdj commented Jul 10, 2025

Copy link
Copy Markdown
Contributor Author

Of course! Wanted to get your feedback first. I was thinking about the limitations of the alternating functionality. This could lead to excessive error logs.

I've re-worked it quite a bit to be more configurable. I'm going to push the changes soon.

- Add familyFallback option to handle connection failures by trying alternate IP versions
- Support two fallback modes:
  - `alternate: false` (default): Try alternate family once, then stick to original
  - `alternate: true`: Continuously alternate between IP versions
- Maintain backward compatibility with existing `family` option
- Add comprehensive test coverage for all fallback scenarios
- Track connection attempts with `_triedFamilyFour` and `_triedFamilySix` flags
- Preserve original family in `_initialFamily` for reference

This improves connection reliability by automatically handling IP version mismatches.

Signed-off-by: David Bauch <jamesbauch@gmail.com>

@bauchdj bauchdj left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feat: implement family fallback for Redis connections

  • Add familyFallback option to handle connection failures by trying alternate IP versions
  • Support two fallback modes:
    • alternate: false (default): Try alternate family once, then stick to original
    • alternate: true: Continuously alternate between IP versions
  • Maintain backward compatibility with existing family option
  • Add comprehensive test coverage for all fallback scenarios
  • Track connection attempts with _triedFamilyFour and _triedFamilySix flags
  • Preserve original family in _initialFamily for reference
  • added JS Docs and updated docs

This improves connection reliability by automatically handling IP version mismatches.

Signed-off-by: David Bauch <jamesbauch@gmail.com>
@bauchdj

bauchdj commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

@mcollina I fixed the test based on the output from the GitHub actions. Please run them again.

@bauchdj

bauchdj commented Aug 5, 2025

Copy link
Copy Markdown
Contributor Author

@mcollina any chance you could re-run the checks? Much appreciated!

@mcollina

mcollina commented Aug 6, 2025

Copy link
Copy Markdown
Collaborator

@bauchdj code looks good. Can you explain why there are many changes to doc?

@bauchdj

bauchdj commented Aug 6, 2025

Copy link
Copy Markdown
Contributor Author

@mcollina When you asked me to update the documentation, I assumed you wanted me to add JS Docs and rerun the docs generation. How would you like me to update the documentation?

Signed-off-by: David Bauch <jamesbauch@gmail.com>
@bauchdj

bauchdj commented Aug 6, 2025

Copy link
Copy Markdown
Contributor Author

@mcollina I reverted the changes to docs. I tested out the docs generation on the JS Docs and they look good. Let me know if there is anything else.

@bauchdj

bauchdj commented Aug 26, 2025

Copy link
Copy Markdown
Contributor Author

@mcollina any update?

@mcollina
mcollina merged commit 2773061 into valkey-io:main Apr 3, 2026
1 check passed
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.

2 participants