fix(utils): include port 65535 in get_free_port() scan range#2024
Open
miclaldogan wants to merge 5 commits into
Open
fix(utils): include port 65535 in get_free_port() scan range#2024miclaldogan wants to merge 5 commits into
miclaldogan wants to merge 5 commits into
Conversation
Contributor
Greptile SummaryThis PR fixes a classic off-by-one error in
Confidence Score: 5/5Minimal, correct single-line fix with no side effects on the surrounding logic. The change is a single range upper-bound adjustment that makes the function's behavior consistent with its own error message. All existing port-scanning logic, error handling, and Ray-reserved-port exclusion remain untouched. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["get_free_port(start_port)"] --> B["for port in range(start_port, 65536)"]
B --> C{Port in Ray reserved range?}
C -- Yes --> B
C -- No --> D["Try socket.bind(localhost, port)"]
D -- Success --> E["Return port"]
D -- OSError --> F{get_next_free_port and port == start_port?}
F -- "False (strict mode)" --> G["Raise RuntimeError: Port in use"]
F -- True --> B
B -- "Exhausted (was: stopped at 65534, now: stops at 65535)" --> H["Raise RuntimeError: No free port found"]
Reviews (6): Last reviewed commit: "Merge branch 'main' into fix/get-free-po..." | Re-trigger Greptile |
range(start_port, 65535) excluded the last valid TCP port (65535). Changed upper bound to 65536 so the loop covers the full valid range 0-65535, consistent with the error message that already referenced 65535. Closes NVIDIA-NeMo#2023 Signed-off-by: miclaldogan <m.iclaldogan@gmail.com>
78f48e1 to
14e3deb
Compare
This was referenced Jun 2, 2026
sarahyurick
approved these changes
Jun 2, 2026
Contributor
|
/ok to test 6ecacb8 |
Contributor
|
/ok to test 954a7eb |
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
range(start_port, 65535)inget_free_port()excluded port 65535, the last valid TCP port65536so the full valid range 0–65535 is coveredChange
Test plan
get_free_port(65535)now succeeds when port 65535 is freeCloses #2023