Repository navigation
fix(cli): validate play and present ports - #6402
Merged
miguel-heygen merged 2 commits intoOct 26, 2026
Merged
Conversation
miguel-heygen
approved these changes
Oct 26, 2026
miguel-heygen
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, this is a nice cleanup as well as a fix. The strict port check already existed twice, in previewPortError and parseRemoteDebuggingPort, and this PR pulls it into one parsePort helper that all three commands use, without adding another copy. Keeping preview's existing message exactly the same is a good touch.
What I checked:
- On main,
play.tsandpresent.tsuseparseInt, so3003oopssilently became 3003 and0/65536passed through.args.portis only read inplay,presentandpreview, and all three now go throughparsePort. - The new early returns use the same
clack.log.error+ exit code 1 pattern these files already use for--remote-debugging-port, and they run before project resolution. - I broke the fix and reran the tests. Switching
playback toparseIntfails all fourplay --portcases, and looseningparsePort(prefix match, allowing 0) fails four cases inport.test.ts. On the PR head all four touched test files pass, 101/101, three runs in a row.
One small, non-blocking nit:
preview.ts:313still parses the port again withparseIntafterpreviewPortErrorhas validated it. It's correct today, but the same flag is parsed by two different rules. Having preview use the value fromparsePortdirectly would leave just one parse. Fine as a follow-up.
CI has finished green at this head.
Verdict: APPROVE
Reasoning: Correct fix that consolidates the existing duplicate port validators, with tests that fail without it, and all checks pass at this head.
SanHsien
added a commit
to SanHsien/hyperframes
that referenced
this pull request
Oct 26, 2026
Merge 20 more upstream commits (acd0bc3..ad4d3fa, v0.8.205: heygen-com#6403, heygen-com#6363, heygen-com#6209, heygen-com#6395, heygen-com#6424, heygen-com#6426, heygen-com#6442, heygen-com#6430, heygen-com#6402, heygen-com#6435, heygen-com#6439, heygen-com#6449, heygen-com#5436, heygen-com#6455 and docs). No conflicts. Record the 11 open PRs heygen-com#6440-heygen-com#6458 and issue heygen-com#6443 in docs/DECISIONS.md (none adopted), re-check the earlier open PRs, and advance the commit watermark to ad4d3fa, the PR watermark to heygen-com#6458 and the issue watermark to heygen-com#6443. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
What
Reject invalid
--portvalues inhyperframes playandhyperframes presentbefore either command resolves a project or starts a server.Why
Both commands previously accepted malformed values such as
3003oopsand silently used port 3003. They also accepted port 0, which cannot produce a reliable advertised player or presenter URL.previewalready rejected the same inputs, so the local-server commands behaved inconsistently.Root cause
playandpresentparsed their port strings withparseInt. JavaScript's prefix parsing accepts trailing non-digits and does not enforce the valid TCP port range.Related work
No related issue or overlapping PR was found. This is a small self-contained correction, so no separate issue was created.
How
playandpresentbefore project resolution and server setup.previewand remote-debugging validation paths so the rules stay consistent.Before and after
Before:
hyperframes play ... --port 3003oops --no-openstarted on port 3003.hyperframes present ... --port 3004oops --no-openstarted on port 3004.After:
--port must be an integer between 1 and 65535.Test plan
Regression tests:
bun run --cwd packages/cli test src/commands/serverPort.test.ts src/utils/port.test.ts src/utils/openBrowser.test.ts src/commands/preview.test.ts: 4 files passed, 101 tests passed.bun run --cwd packages/cli typecheck: passed.bun run build: passed after rebasing onto current main.bun run lint: passed with 0 warnings and 0 errors.COMMENT_CHECK_BASE=upstream/main node scripts/check-comment-citations.mjs: passed, 7 files examined.COMMENT_CHECK_BASE=upstream/main node scripts/comment-ratchet.mjs: passed, 5 changed source files.playandpresentvalues both returned exit code 1 with the expected message.A full CLI test run was also attempted locally: 5,938 tests passed, 105 skipped, and 10 unrelated environment-sensitive tests failed. An untouched upstream worktree reproduced the stable failures involving macOS
/varpath canonicalization, an installed systemwhisper-cli, unavailable WebGL contexts, and Node deprecation output; filesystem-watcher and proxy teardown failures were intermittent under the concurrent full run.Compatibility
The parser is platform-independent. This was executed on macOS only, so this PR makes no Windows test claim. Valid port values, default ports, browser launch behavior, and server fallback behavior are unchanged.