Skip to content

Conversation

bauchdj
Copy link

@bauchdj bauchdj commented Jul 9, 2025

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)

Copy link
Collaborator

@mcollina mcollina left a comment

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
Copy link
Author

bauchdj commented Jul 10, 2025

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 <[email protected]>
Copy link
Author

@bauchdj bauchdj left a comment

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.

@bauchdj
Copy link
Author

bauchdj commented Jul 28, 2025

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

@bauchdj
Copy link
Author

bauchdj commented Aug 5, 2025

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

@mcollina
Copy link
Collaborator

mcollina commented Aug 6, 2025

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

@bauchdj
Copy link
Author

bauchdj commented Aug 6, 2025

@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 <[email protected]>
@bauchdj
Copy link
Author

bauchdj commented Aug 6, 2025

@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
Copy link
Author

bauchdj commented Aug 26, 2025

@mcollina any update?

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