-
Notifications
You must be signed in to change notification settings - Fork 454
feat: [ENG-2857] surface port-in-use error in brv webui #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ncnthien
wants to merge
10
commits into
main
Choose a base branch
from
feat/ENG-2857
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
83bd7f5
feat: [ENG-2857] surface port-in-use error in brv webui
ncnthien 7045f28
feat: [ENG-2857] address PR feedback — explicit status discriminator,…
ncnthien 3b3896d
feat: [ENG-2857] gate httpServer cleanup to startup phase to avoid we…
ncnthien 96337b3
Merge branch 'main' into feat/ENG-2857
ncnthien 8838e8e
Merge branch 'main' into feat/ENG-2857
ncnthien 6d3fa5d
feat: [ENG-2857] auto-fallback Web UI to next port when default is in…
ncnthien adbb0d3
feat: [ENG-2857] extract testable fallback helper + honor explicit po…
ncnthien 469796e
feat: [ENG-2857] explicit status on StartWebUiOutcome, split ok varia…
ncnthien 77ba89f
feat: [ENG-2857] revert CLI URL to localhost per product preference
ncnthien 1bd56b5
feat: [ENG-2857] untrack MANUAL_TEST_ENG-2857.md (local QA artifact)
ncnthien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| # Manual Test Plan — ENG-2857 | ||
|
|
||
| PR: https://github.com/campfirein/byterover-cli/pull/704 | ||
| Scope: `brv webui` port handling | ||
| - Auto-fallback to the next free port when the default (7700) is taken | ||
| - Specific, actionable error messages for port conflicts | ||
| - Strict behavior for explicit choices (`--port`, `BRV_WEBUI_PORT`, persisted preference) | ||
|
|
||
| --- | ||
|
|
||
| ## Pre-test setup | ||
|
|
||
| ```sh | ||
| # 1) Build so dist/ matches the PR head | ||
| npm run build | ||
|
|
||
| # 2) Clean state — stop daemon + clear persisted port preference | ||
| ./bin/dev.js restart | ||
| rm -f "$HOME/Library/Application Support/brv/webui-config.json" | ||
| ``` | ||
|
|
||
| > **Tip:** All hogs in this plan bind `127.0.0.1` (IPv4) explicitly. A bare `listen(7700)` in Node binds IPv6 by default, which does **not** conflict with our daemon's IPv4 socket and gives a misleading "happy path" result. | ||
|
|
||
| --- | ||
|
|
||
| ## Test 1 — Happy path on default port | ||
|
|
||
| ```sh | ||
| ./bin/run.js webui | ||
| ``` | ||
|
|
||
| **Expect:** | ||
| ``` | ||
| ByteRover Web UI: http://localhost:7700 | ||
| ``` | ||
| Browser opens. | ||
|
|
||
| --- | ||
|
|
||
| ## Test 2 — Auto-fallback on the default port | ||
|
|
||
| In a separate terminal, hold port 7700 (IPv4): | ||
|
|
||
| ```sh | ||
| node -e "require('node:http').createServer((_,r)=>r.end()).listen(7700,'127.0.0.1',()=>console.log('hog'))" | ||
| ``` | ||
|
|
||
| Back in the brv terminal: | ||
|
|
||
| ```sh | ||
| ./bin/dev.js restart # respawn daemon while 7700 is held | ||
| ./bin/run.js webui | ||
| ``` | ||
|
|
||
| **Expect:** | ||
| ``` | ||
| Port 7700 was in use — using port 7701 instead. | ||
| ByteRover Web UI: http://localhost:7701 | ||
| ``` | ||
|
|
||
| The browser should open and successfully reach the Web UI on 7701. | ||
|
|
||
| --- | ||
|
|
||
| ## Test 3 — Explicit `--port` is strict (no fallback) | ||
|
|
||
| With 7700 still held from Test 2: | ||
|
|
||
| ```sh | ||
| ./bin/run.js webui --port 7700 | ||
| ``` | ||
|
|
||
| **Expect:** | ||
| ``` | ||
| Error: Web UI port 7700 is already in use. Run `brv webui --port <port>` to choose a different port. | ||
| ``` | ||
|
|
||
| Verify there is **no** silent fallback. The user explicitly typed 7700; we honor their choice strictly. | ||
|
|
||
| --- | ||
|
|
||
| ## Test 4 — Explicit env var is strict | ||
|
|
||
| ```sh | ||
| ./bin/dev.js restart | ||
| BRV_WEBUI_PORT=7700 ./bin/run.js webui | ||
| ``` | ||
|
|
||
| **Expect:** Same `Error: Web UI port 7700 is already in use...` message. Env var is treated as explicit intent — no auto-fallback. | ||
|
|
||
| --- | ||
|
|
||
| ## Test 5 — Persisted preference is strict | ||
|
|
||
| Free 9090 and clear hogs first, then set up the scenario: | ||
|
|
||
| ```sh | ||
| # In the hog terminal: Ctrl-C the 7700 hog | ||
| npx kill-port 7700 | ||
|
|
||
| # Persist 9090 as the preferred port via setPort | ||
| ./bin/dev.js restart | ||
| ./bin/run.js webui --port 9090 | ||
| # (expect happy path on 9090) | ||
| ``` | ||
|
|
||
| Now hog 9090 and restart so the daemon hits the persisted preference at boot: | ||
|
|
||
| ```sh | ||
| # In the hog terminal: | ||
| node -e "require('node:http').createServer((_,r)=>r.end()).listen(9090,'127.0.0.1',()=>console.log('hog'))" | ||
|
|
||
| # In the brv terminal: | ||
| ./bin/dev.js restart | ||
| ./bin/run.js webui | ||
| ``` | ||
|
|
||
| **Expect:** | ||
| ``` | ||
| Error: Web UI port 9090 is already in use. Run `brv webui --port <port>` to choose a different port. | ||
| ``` | ||
|
|
||
| The daemon honored the persisted preference strictly instead of silently shifting to 9091. | ||
|
|
||
| --- | ||
|
|
||
| ## Test 6 — Connection-failure path still routes through the generic handler | ||
|
|
||
| ```sh | ||
| ./bin/dev.js restart # kill daemon | ||
| BRV_IAM_BASE_URL='' ./bin/run.js webui # makes daemon spawn fail | ||
| ``` | ||
|
|
||
| **Expect:** A daemon-connection error, e.g. | ||
| ``` | ||
| Error: Connection error: Failed to start daemon: timed out waiting for daemon to become ready | ||
| Run 'brv restart' if the daemon is unresponsive. | ||
| ``` | ||
|
|
||
| This must **not** be any of the new port-conflict messages — confirms the new error branches don't accidentally swallow connection-layer errors. | ||
|
|
||
| --- | ||
|
|
||
| ## Cleanup | ||
|
|
||
| ```sh | ||
| # Free any port hogs | ||
| npx kill-port 7700 9090 9091 2>/dev/null | ||
|
|
||
| # Reset state | ||
| ./bin/dev.js restart | ||
| rm -f "$HOME/Library/Application Support/brv/webui-config.json" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Pass criteria | ||
|
|
||
| - [ ] Test 1: URL is `http://127.0.0.1:7700`, browser opens. | ||
|
ncnthien marked this conversation as resolved.
Outdated
|
||
| - [ ] Test 2: Fallback notice prints; URL shifts to 7701; browser opens on 7701. | ||
| - [ ] Test 3: `--port 7700` fails strictly, no fallback attempted. | ||
| - [ ] Test 4: `BRV_WEBUI_PORT=7700` fails strictly, no fallback attempted. | ||
| - [ ] Test 5: Persisted preference 9090 fails strictly when 9090 is held, no shift to 9091. | ||
| - [ ] Test 6: Daemon-spawn failure produces a "Connection error: ..." message, not a port message. | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| export class WebUiError extends Error { | ||
| public constructor(message: string) { | ||
| super(message) | ||
| this.name = 'WebUiError' | ||
| } | ||
| } | ||
|
|
||
| export class WebUiPortInUseError extends WebUiError { | ||
| public readonly port: number | ||
|
|
||
| public constructor(port: number) { | ||
| super(`Web UI port ${port} is already in use`) | ||
| this.name = 'WebUiPortInUseError' | ||
| this.port = port | ||
| } | ||
| } | ||
|
|
||
| export class WebUiServerAlreadyRunningError extends WebUiError { | ||
| public constructor() { | ||
| super('Web UI server is already running') | ||
| this.name = 'WebUiServerAlreadyRunningError' | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.