Repository navigation
test(conformance): retry a launch only when a stranger owns its port - #247
Conversation
The launch conformance cases reserve a port with `freePort()` and launch the fixture on it. The reservation holds only for an instant: another worker can bind the number first, our fixture dies of `EADDRINUSE`, and the readiness probe is answered by the stranger — so the case reads `ready: true` with `still_running: false` and fails although `uvp_run` behaved correctly (#246). `launchOnReservedPort` re-reserves and retries at most three times, gated on evidence: either the child's own `EADDRINUSE` in `stderr_tail`, or a probe showing a listener answering right now. The ambiguous pair alone is not evidence — a service that answered and then died leaves the same pair, and that is a defect the case must still fail on. The gate is a pure predicate (`launchWasOvertaken`) with a table over its combinations; a forced collision proves the retry end to end, and an exhaustive bound reports a premise that never held rather than a handler defect. Addresses #246. Assisted-by: Claude Code (Antruly-dev-1)
Review —
|
|
Owner approval. Approved at Reviewed in this comment. No blocking findings: the retry is gated on evidence rather than on the ambiguous pair, the bound turns a systematic misobservation into a failure rather than a pass, and the forced-collision test exercises the ordering that produced #246. The three non-blocking notes recorded there (the At this head: focused suite 94 passed, Merging as a merge commit at the exact reviewed head. Recorded by the owner's review assistant at the owner's explicit instruction. |
🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1
What this changes
The launch conformance cases reserve a port with
freePort(), which holds it only for the instant between the check and the fixture's own bind. A worker elsewhere can take the number in that window; the fixture then printsError: listen EADDRINUSE …and exits, while the readiness probe is answered by the stranger — every conformance fixture serves/healthz. The case observesready: truewithstill_running: falseand fails, even thoughuvp_runbehaved correctly (#246, observed on #245's attempt 1: 141 ms, no diff in the launching code).The change follows the issue's second option — a bounded, evidence-gated retry — with the gate made testable:
launchWasOvertaken(run, portStillAnswers)is the decision, as a pure predicate: the ambiguous pair alone (ready: true,still_running: false) is not evidence. It also requires either the child's ownEADDRINUSEinstderr_tail, or a probe showing a listener answering on the port right now. A service that answered and then died leaves the same pair, and that is a real defect — it must fail, not be retried.launchOnReservedPort(launch)re-reserves the port and retries at most 3 times, only when the gate says yes. When all attempts are overtaken it throws with a message saying the case never launched its own listener, rather than asserting a handler defect.expectConforms("uvp_run", run)stays at each call site so a retried run is still checked against the contract.Nothing in
src/changes; the handler is not altered. This does not establish that the takeover was the cause of any other failure: it makes that collision distinguishable from a defect and stops the collision from reddening an unrelated PR.Addresses #246.
Tests
New tests in
tests/conformance/handlers.test.ts:ready: falseandstill_running: true);Local gate
Run in
/tmp/wt246at083c7bc, the tree pushed here (Linux host;LIBUVCPP_ROOT=/home/zwy/下载/libuvcpp-1.7.0-linux-x64,PKG_CONFIG_PATH=$LIBUVCPP_ROOT/lib/pkgconfig,LD_LIBRARY_PATH=$LIBUVCPP_ROOT/libfor the second run):npm ci,npm run compile— exit 0npm run test:local -- tests/conformance/handlers.test.ts— 94 passednpx tsc --noEmit -p tsconfig.json— exit 0npm run lint— exit 0oxfmt --check— cleannpm run knip— exit 0npm run check:pr— exit 0 twice on this tree:LIBUVCPP_ROOT/PKG_CONFIG_PATH/LD_LIBRARY_PATHset to the 1.7.0 install: 13/13 tasks, 77 files passed / 2 skipped, 1432 passed / 14 skipped,doc facts … libuvcpp 1.7.0 … consistent,sbom:checkand licence check up to date. The remaining skips name their reasons: the native probe is not built here (npm run build:native-probeagainst a CAPI-enabled libuvcpp — the two HTTP/3 lanes), the published-package lane is opt-in, and three tests are Windows-only.c63fd8a2508a1e6645b0c23a9ead10ee): removingready === true/still_running !== true/ theEADDRINUSEarm / theportAnswersarm from the gate, removing the retry branch's!launchWasOvertakenreturn, and changing the attempt bound each turn at least one test red — all six killed.Limits
freePort()'s reservation window is unchanged, and other suites that reserve-then-launch have the same window.EADDRINUSEreachingstderr_tailwould still fail — no evidence, no retry.Never merged without the owner's explicit approval on this PR.
Assisted-by: Claude Code (Antruly-dev-1)