fix(cli): make local startup collision-safe - #609
Merged
Conversation
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.
Summary
Root cause
The released smoke test always passed
--port 0, so it skipped the default port-selection path. On macOS, a service listening on the IPv6 wildcard could own port 3000 while the CLI's IPv4 bind probe still appeared to succeed. Pascal then started on 3000, health requests reached the foreign app, and the CLI waited for the full health timeout.Verification
bunx biome check packages/cli/README.md packages/cli/scripts/smoke-packed-runtime.ts packages/cli/src/bin/pascal.ts packages/cli/src/editor-process.ts packages/cli/src/runtime.test.ts packages/cli/src/terminal-progress.ts packages/cli/src/terminal-progress.test.tsbun run --cwd packages/cli check-typesbun test packages/cli/src(23 pass)bun run --cwd packages/cli buildbun run --cwd packages/cli build-runtimebun run --cwd packages/cli stage-runtimebun run --cwd packages/cli smoke-runtimeNote
Medium Risk
Changes default binding and port/health logic for the managed local editor process; behavior is covered by new tests and smoke coverage but affects every local start path.
Overview
Makes local editor startup avoid port clashes and fail fast when something else is already listening.
Port selection now defaults to an OS-assigned free loopback port (
preferredPort0 instead of 3000). If you pass--port <n>and that port already accepts connections, Pascal picks another port automatically instead of probing a fixed range or erroring. README documents this behavior.Health checks distinguish Pascal from other apps on the same port: a non-matching
/api/healthresponse raisesport_conflictimmediately instead of waiting out the full health timeout.Interactive
pascal editor(non---json) shows staged progress via newTerminalProgressandEditorStartProgresscallbacks throughstartEditor. First-time runtime installs get a short “next steps” block (status,logs --follow,stop).Tests and smoke: packed-runtime smoke occupies port 3000 (IPv6 wildcard) and asserts the editor does not bind there; unit tests cover occupied-port fallback and fast foreign-health failure.
Reviewed by Cursor Bugbot for commit 6181f60. Bugbot is set up for automated code reviews on this repo. Configure here.