Skip to content

fix(cli): treat --port=N as an explicitly passed port - #795

Merged
Ishaan Gangwani (ishaan1124) merged 2 commits into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/cli-explicit-port-flag
Sep 29, 2026
Merged

Ishaan Gangwani (ishaan1124) merged 2 commits into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/cli-explicit-port-flag

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

What

resolveNetworkOptions decided whether a port was passed with an exact string match:

const portExplicitlySet = process.argv.includes("--port")
const port = portExplicitlySet ? args.port : (config?.server?.port ?? args.port)

Why it matters

yargs parses --port 5555 and --port=5555 into the same args.port. The argument is right either way; what differs is whether the flag that decides to trust it over the config file. So with server.port in openscience.json:

openscience serve --port 5555   ->  listens on 5555
openscience serve --port=5555   ->  listens on 1234 (from the config)

The = form is the more common spelling in scripts, CI, and docs snippets, so the port a user explicitly typed is discarded and the server binds somewhere they did not ask for — with no warning, and a clean startup that reads as the flag having been honoured.

Verification

New file — src/cli/network.ts had no unit test at all. Fails before, passes after:

error: expect(received).toBe(expected)
Expected: 5555
Received: 1234
(fail) a port passed as --port=N beats the configured port
(pass) a port passed as --port=N beats the configured port
(pass) a port passed as --port N beats the configured port
(pass) the configured port applies when no port was passed
(pass) the parsed port applies when neither the command line nor the config sets one
(pass) cors origins from the config and the command line are combined
 5 pass
 0 fail

Both spellings are pinned side by side, plus the two fallback paths and the existing CORS merge, so the precedence rule is now fully covered.

The change

-  const portExplicitlySet = process.argv.includes("--port")
+  // Both spellings reach here as the same parsed argument, so an exact match
+  // on the bare word let "--port=5555" be treated as not passed and quietly
+  // lose to server.port from the config.
+  const portExplicitlySet = process.argv.some((arg) => arg === "--port" || arg.startsWith("--port="))

bun run typecheck clean; touched files are Prettier-clean (checked on LF-normalized copies — this checkout has core.autocrlf=true, which makes Prettier flag every file in the repo).

Fixes #794

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

ANIRUDDHA ADAK (@aniruddhaadak80) is attempting to deploy a commit to the InkVell Team on Vercel.

A member of the Team first needs to authorize it.

The detection matched only the bare word --port, so --port=5555 was parsed by yargs into the same argument but never counted as passed, and server.port from the config won silently.
@ishaan1124
Ishaan Gangwani (ishaan1124) merged commit cab7657 into synthetic-sciences:main Sep 29, 2026
2 of 3 checks passed
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.

openscience --port=5555 is silently ignored when server.port is set in the config

2 participants