Skip to content

check open ports for which address families we can bind to#5621

Merged
adhami3310 merged 1 commit into
mainfrom
khaleel/eng-6826-reflex-fails-to-start-up-on-systems-without-ipv6-support
Jul 24, 2025
Merged

check open ports for which address families we can bind to#5621
adhami3310 merged 1 commit into
mainfrom
khaleel/eng-6826-reflex-fails-to-start-up-on-systems-without-ipv6-support

Conversation

@adhami3310
Copy link
Copy Markdown
Member

fixes #5617

@linear
Copy link
Copy Markdown

linear Bot commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR fixes a critical startup issue on systems without IPv6 support by introducing dynamic address family detection for port checking. Previously, Reflex would fail to start on IPv6-disabled systems because the is_process_on_port() function always attempted to check both IPv4 and IPv6 ports, causing an OSError when trying to create IPv6 sockets on unsupported systems.

The solution adds a new helper function _can_bind_at_any_port() that tests whether a given address family (IPv4 or IPv6) is available for binding by attempting to create and bind a socket. This function gracefully handles exceptions and returns a boolean result. The is_process_on_port() function now accepts an optional address_families parameter, allowing callers to specify which address families to check.

Most importantly, the handle_port() function (which manages port assignment for services) now filters the address families list to only include those that are actually supported by the system before checking port availability. If no address families are available, it provides a clear error message about network configuration issues.

This change integrates seamlessly with the existing process management utilities in processes.py, maintaining backward compatibility while fixing the IPv6-related startup failure. The solution is defensive and handles edge cases like systems with severe network misconfigurations.

Confidence score: 4/5

• This PR is very safe to merge and directly addresses a documented startup failure issue
• The implementation is robust with proper error handling and maintains backward compatibility
• No files need additional review - the changes are well-contained and the logic is sound

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jul 24, 2025

CodSpeed Performance Report

Merging #5621 will not alter performance

Comparing khaleel/eng-6826-reflex-fails-to-start-up-on-systems-without-ipv6-support (dfc346e) with main (b052299)

Summary

✅ 8 untouched benchmarks

@adhami3310 adhami3310 merged commit c9c4203 into main Jul 24, 2025
41 checks passed
@adhami3310 adhami3310 deleted the khaleel/eng-6826-reflex-fails-to-start-up-on-systems-without-ipv6-support branch July 24, 2025 17:58
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.

Reflex fails to start up on systems without IPv6 support

2 participants