Repository navigation
test(web): bind the auto-open server to :0 instead of probing a free port - #2669
Merged
Merged
Conversation
…#2602) findFreePort() closed its probe socket before startHonoServer bound the port, so under load another process could take it and the server's EADDRINUSE handler process.exit(1)'d the run. Bind :0 and read the real port back from the URL handed to the opener, which the banner builds from the bound port. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The focused test-only change correctly resolves #2602 without altering production behavior.
0 open findings
What changed in this PR
Eliminates a flaky port-selection race in the web server auto-open integration test.
Changes:
- Binds the test server directly to ephemeral port
0. - Derives and validates the assigned port from the mocked browser URL.
- Removes the obsolete free-port probe.
| File | Description |
|---|---|
clients/web/src/test/integration/server/server-auto-open.test.ts |
Uses race-free ephemeral binding and strengthens startup assertions. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Member
Author
|
Copilot review loop closed after round 1, which was clean: 0 inline comments, "0 open findings" in the headline, and no suppressed comments. Per the pr-flow exit rule, no confirming round was requested. |
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.
Closes #2602
What changed
server-auto-open.test.tsused to callfindFreePort(): it bound:0, read the port, closed the probe socket, and passed the number tostartHonoServer, which bound it later. On a loaded machine another process could take the port in between, andserver.ts'sEADDRINUSEhandler then calledprocess.exit(1), failinglocal:gate.The test now passes
port: 0tostartHonoServer, so the server owns its port from the moment the kernel picks it. It reads the real port back from the URL handed to the (mocked) opener. That URL is the banner URL, whichprintServerBannerbuilds from the bound port (info.port).findFreePortand itsnode:netimport are removed.server.ts. As the issue asks, this is a fix to the test, not to the server's handling of a port that is really taken (Race condition: 'PORT IS IN USE' error caused by Inspector's own process #1090).startHonoServeralready accepted0and already reported the bound port through the banner, so no new API was needed.allowedOriginsis now[], because the origin isn't known until after the bind. The test only fetches/, and the allow-list guards only/api/*.127.0.0.1URL on a nonzero port, and that URL's origin serves/with 200.Verification
server-auto-open.test.ts: 4/4 passing.npm run local:gate: green throughlocal:validate,local:dco,verify:skills:cli,coverage,verify:build-gate,verify:bundle-externalsandsmoke.smoke:web:firefoxfails to launch Firefox on the maintainer's macOS 27 machine (smoke:web:firefox cannot launch Playwright's Firefox on macOS 27 #2625), which stops the chain. So that pass ran in the Linux Playwright container (mcr.microsoft.com/playwright:v1.62.1-noble, cleangit archiveexport) and passed.local:storybookwas run on its own and passed (123 files, 529 tests).auth/node/storage.test.ts, which clears the real~/.mcp-inspectorOAuth store that all worktrees share. That's filed as Flaky: OAuth storage test clears the real ~/.mcp-inspector store, racing other worktrees #2668 and kept out of this PR.🤖 Generated with Claude Code