Skip to content

fix: don't override --port=0 with the default port#619

Open
gabrielcnb wants to merge 1 commit into
giggio:mainfrom
gabrielcnb:fix-port-zero
Open

fix: don't override --port=0 with the default port#619
gabrielcnb wants to merge 1 commit into
giggio:mainfrom
gabrielcnb:fix-port-zero

Conversation

@gabrielcnb

Copy link
Copy Markdown

passing --port=0 to start() is silently ignored.

getPortFromArgs returns the number 0, and the if (!port) check treats 0 as falsy, so it overrides the user's request with --port=9515. --port=0 is a valid way to ask the os for a free ephemeral port, which is useful to avoid the fixed 9515 collision when running parallel instances on ci.

changes:

  • check port === undefined instead of !port, so only a missing port triggers the default.
  • in the promise path, resolve immediately when port === 0. the os picks a random port we can't know here, so tcpPortUsed.waitUntilUsed(0, ...) would just time out and reject.

added tests for the default port, --port=0, and an explicit port. npm test, lint and typecheck pass.

getPortFromArgs returns 0 for --port=0, which the falsy check treated as
no port and overrode with --port=9515, dropping the user's request for an
os-assigned ephemeral port. check for undefined instead, and resolve the
start() promise immediately for port 0 since the chosen port is unknown
and cannot be polled.
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

🚦Reports 🚦

Reports will be posted here as they become available.

@gabrielcnb

gabrielcnb commented Jun 6, 2026

Copy link
Copy Markdown
Author

tested locally before opening: npm test (19 passing), lint and typecheck pass. the build here is waiting on approval to run.

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.

1 participant