Refuse a start when the port is held on the other loopback - #453
Open
kevin9327 wants to merge 1 commit into
Open
Refuse a start when the port is held on the other loopback#453kevin9327 wants to merge 1 commit into
kevin9327 wants to merge 1 commit into
Conversation
The readiness check accepts an answer at 127.0.0.1 or at [::1], because a process binds whichever loopback its runtime resolved `localhost` to. The guard in front of it asked only 127.0.0.1, so a port held on ::1 alone was reported free and the start went ahead into it -- the one outcome that guard exists to prevent. Both addresses are asked now.
kevin9327
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso and
tylerslaton
as code owners
September 8, 2026 22:23
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
The desktop shell refuses to start when something already holds a port the deployment needs. That
refusal asked one loopback address; the readiness check immediately after it accepts an answer at
either. So a port held on
::1alone was reported free, and the start went ahead into it — which isprecisely the case
port_already_takenwas written for.The gap
stack.rsalready records why one loopback is not enough, next to the readiness check:answering_athonours that and tries both. The guard in front of it did not:The two therefore disagreed about what "this port is in use" means, and the guard is the half whose
own documentation says what that costs:
A holder on
::1slipped past the check and left the start to fail later, on something that names aprocess rather than the port in the way.
The change
One helper, asking both loopback addresses. Nothing else moves: same message, same 300 ms, same
call sites.
Failing first
The test binds a listener on
[::1]:0and asks the guard about the port it got. Againstmain'sstack.rs:With the change:
85 of those 86 are the suite as it stands on
main, all still passing.Against over-correcting
The two cases that must stay accepted are already pinned by tests that ran before and after, both
green in each run above:
a_port_nobody_holds_is_not_reported_as_taken— port 1, which nothing is listening on, must notbecome a problem now that a second address is asked.
a_held_port_is_named_along_with_what_uses_it— the IPv4 case, unchanged, still named with itsport and its purpose.
A refused connection comes back at once on both addresses, so the extra question does not add the
300 ms timeout to a start on a free port.
Verified with
clippy finished with no warnings on the crate;
fmt --checkis clean.Note on the changelog
A deployment behaves differently afterwards — a start that used to go ahead now stops and names the
port — so there is a
## Unreleasedentry. It shares that anchor with other open pull requests andmay need a one-line rebase.