fix: distinguish AddrInUse from transient IPv6 bind failures in port checker#2640
Merged
domenkozar merged 4 commits intoMar 20, 2026
Merged
Conversation
domenkozar
reviewed
Mar 20, 2026
This was referenced Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes false-positive "Port X is already in use" errors when
--strict-portsis enabled and the nix evaluation cache is invalidated.bind_no_reusenow returns the actualio::Errorinstead of discarding it as()reserve_portonly treatsAddrInUseerrors from the IPv6 bind as genuine port conflictsProblem
On macOS, after a clean
devenv upshutdown (all processes confirmed dead,lsofshows no listeners), restarting immediately can fail with "Port 6380 is already in use" but only when:--strict-portsis enabledThe port is not actually in use.
lsofconfirms nothing is listening andget_process_using_portfinds no PID. The issue is thatbind_no_reuseon[::1]:portcan fail for non-AddrInUsereasons on macOS, and the previous code assumed any IPv6 bind failure meant the port was occupied.Test plan
test_bind_no_reuse_returns_addr_in_use_errorto verify error kind propagationtest_reserve_port_succeeds_when_ipv4_freeto verify strict mode works on free portstest_strict_mode_fails_only_on_genuine_conflictto verify real conflicts are still detected