-
-
Notifications
You must be signed in to change notification settings - Fork 199
Fix: support configurable Electron ports and free port fallback #1460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ramarivera
wants to merge
6
commits into
MCPJam:main
Choose a base branch
from
ramarivera:codex/fix-dynamic-port-detection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f280bd7
fix(port): support configurable/free electron and cli ports
ramarivera 63fd30b
fix: align port scan host/availability checks
ramarivera 0947472
fix: harden CLI/Electron port probe edge cases
ramarivera 04bd581
fix: allow probing maxPort == startPort in start.js
ramarivera 73a4d71
docs: add fork/local testing instructions
ramarivera b6c5292
Revert "docs: add fork/local testing instructions"
ramarivera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Truthiness vs. identity:
"0"and""silently become port 6274 yet are treated as explicit.Line 699 uses a truthiness test — falsy strings like
"0"or""fall through to the default6274. But line 710 uses!== undefined, so those same values are considered explicitly requested. The result:--port 0orSERVER_PORT=""silently checks 6274 as if the user asked for it, yielding a confusing error ("Explicitly requested port 6274 is not available") or quiet success on a port the user never intended.Align the two checks so
parsePortis the single arbiter of validity:Proposed fix
const requestedPortCandidate = process.env.SERVER_PORT !== undefined ? process.env.SERVER_PORT : envVars.PORT; - const requestedPort = requestedPortCandidate - ? parsePort(requestedPortCandidate) - : 6274; + const requestedPort = + requestedPortCandidate !== undefined && requestedPortCandidate !== "" + ? parsePort(requestedPortCandidate) + : 6274; let PORT; const defaultHost = process.env.ENVIRONMENT === "dev" ? "localhost" : "127.0.0.1"; const baseHost = process.env.HOST || defaultHost; const host = baseHost; try { // Check if user explicitly set a port via --port flag - const hasExplicitPort = requestedPortCandidate !== undefined; + const hasExplicitPort = + requestedPortCandidate !== undefined && requestedPortCandidate !== "";This way
--port 0produces the clear"Invalid port value: 0"error fromparsePort, and an emptySERVER_PORT=""falls through to the default scan — both matching user intent.🤖 Prompt for AI Agents