Skip to content

fix: validate --listen port numbers instead of crashing with RangeError - #866

Closed
charan-rathore wants to merge 1 commit into
vercel:mainfrom
charan-rathore:fix-listen-port
Closed

charan-rathore wants to merge 1 commit into
vercel:mainfrom
charan-rathore:fix-listen-port

Conversation

@charan-rathore

Copy link
Copy Markdown

Related Issues

No tracking issue; found while testing the CLI.

Description

Changed

  • parseEndpoint now checks that a numeric endpoint is an integer from 0 to 65535 and throws Invalid port number: <value> otherwise, for both bare ports and tcp:// endpoints. Before, serve --listen 99999 (also negative, fractional, non-finite, or tcp://host:99999) went straight to the socket layer and crashed with a raw RangeError [ERR_SOCKET_BAD_PORT] stack trace.
  • The error is thrown the same way as the existing invalid-endpoint errors.
  • Added 5 cases to the existing invalidEndpoints table in tests/cli.test.ts, and a patch changeset.

Caveats/Problems/Issues

Exactly the 5 new cases fail on the unpatched base; tests/cli.test.ts passes 16/16 with the change. Compiled CLI: --listen 99999 and --listen 3000.5 print "Invalid port number: ..." and --listen 4117 serves HTTP 200. Tests ran through pnpm test (the repo config); bare vitest shows a help-text snapshot mismatch that is also present on the base.

Checklist

  • The issues that this PR fixes/closes have been mentioned above.
  • What this PR adds/changes/removes has been explained.
  • All tests (pnpm test) pass.
  • The linter (pnpm lint) does not throw an errors.
  • All added/modified code has been commented, and
    methods/classes/constants/types have been annotated with TSDoc comments.

@vercel

vercel Bot commented Oct 1, 2026

Copy link
Copy Markdown

@charan-rathore is attempting to deploy a commit to the Internal Playground Team on Vercel.

A member of the Team first needs to authorize it.

@charan-rathore

Copy link
Copy Markdown
Author

This one has been quiet, so I am closing it for now. Happy to reopen if it becomes useful.

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