Skip to content

fix(test): target the actual bound port when a dev/prod server rebinds#716

Merged
natew merged 1 commit into
mainfrom
fix/test-server-port-race
Jun 9, 2026
Merged

fix(test): target the actual bound port when a dev/prod server rebinds#716
natew merged 1 commit into
mainfrom
fix/test-server-port-race

Conversation

@natew

@natew natew commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Problem

Intermittent tests-job flake (seen on PR #715's first run): tests/test-loaders setup timed out —

Starting a dev server on http://localhost:53414
Still waiting for http://localhost:53414... (30s) ... (242s)
Setup error: Server at http://localhost:53414 did not start within ... 242721ms
  Logs: ... Port 53414 is in use, trying another one... Server running on http://localhost:<other>/

vxrn/vite rebind to a different port when the requested one is taken — a check-then-bind race when many test packages start concurrently under turbo (the existing random-port-base + killProcessOnPort mitigations reduce but don't eliminate it). When it happens, both the readiness check and ONE_SERVER_URL (built from testDevPort/testProdPort in setup.ts) keep pointing at the requested-but-vacated port → 242s timeout. Native iOS tests are unaffected (fixed ports).

Fix

resolveBoundServerUrl(requestedUrl, output) parses the actual bound port from the server's stdout and waitForServer polls/returns it; the caller uses it for testDevPort/testProdPort. Conservative: only deviates when the server reports Port <n> is in use, so the common no-move path is byte-for-byte unchanged.

Verification (local)

  • resolveBoundServerUrl exercised across happy / trailing-slash / moved-port / move-without-new-url cases → all correct.
  • Happy path e2e: test-loaders test:dev → 35 passed, 8 skipped, readiness check fired normally (Server at http://localhost:51982 is ready after 7854ms).
  • typecheck (@vxrn/test) exit 0 · oxlint 0/0.
  • (@vxrn/test exports from src, so no build step; the PR's own tests job re-runs the full web suite as the safety gate.)

vxrn/vite rebind to a different port when the requested one is taken (a
check-then-bind race when test packages start concurrently under turbo).
The readiness check and ONE_SERVER_URL kept targeting the requested-but-
vacated port, so setup timed out — e.g. test-loaders flaking with
'Server at http://localhost:53414 did not start ... 242721ms'.

Parse the actual bound port from the server's output (resolveBoundServerUrl)
and use it for the readiness poll and the returned testDevPort/testProdPort.
Conservative: only deviates when the server reports the requested port was in
use, so the common (no-move) path is unchanged.
@railway-app railway-app Bot temporarily deployed to onestack.dev / one-pr-716 June 9, 2026 08:04 Destroyed
@railway-app

railway-app Bot commented Jun 9, 2026

Copy link
Copy Markdown

🚅 Deployed to the one-pr-716 environment in onestack.dev

Service Status Web Updated (UTC)
one ✅ Success (View Logs) Web Jun 9, 2026 at 8:07 am

@natew natew added this pull request to the merge queue Jun 9, 2026
Merged via the queue into main with commit 453023f Jun 9, 2026
3 checks passed
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