Repository navigation
fix(qa): prevent reserved gateway port startup deadlock - #126370
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 1:28 PM ET / 17:28 UTC. ClawSweeper reviewWhat this changesThe PR closes probe connections accepted by a reserved QA Gateway port, preventing port release from waiting before the real Gateway can start. Merge readinessNo blocking defect was found in the focused QA repair. This maintainer-labeled PR should remain open for explicit maintainer handling until its required exact-head checks finish. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherQA Lab reserves a local Gateway port while staging configuration and authentication, then releases it immediately before starting an isolated Gateway process. This change ensures incidental probe connections cannot block that handoff. flowchart LR
A[QA scenario] --> B[Reserve local Gateway port]
B --> C[Stage configuration and auth]
C --> D[Release reservation]
D --> E[Start isolated Gateway]
E --> F[Run real-process QA checks]
Decision needed
Why: The protected maintainer label requires a human landing decision even though no code-level blocker was found. Before merge
Agent review detailsSecurityNone. PR surfaceSource +2, Tests +25. Total +27 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep accepted-socket cleanup at the port-reservation owner and land after maintainer review and green exact-head CI. Do we have a high-confidence way to reproduce the issue? Yes. Opening a TCP probe to the reserved loopback port before release exercises the source-proven wait condition; the focused regression directly covers that sequence. Is this the best way to solve the issue? Yes. Closing probes at the reservation owner removes the blocking connection without altering the real Gateway or adding a downstream timeout. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 957f013454d4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready proof for exact head 31c2a3707e6432f1137c6e34882f872258a200fb:
Maintainer decision: land. Destroying accepted probes at the QA Gateway reservation owner fixes the release deadlock while keeping socket creation at the existing Gateway-child network boundary; retries, timeout increases, a new CodeQL classification, or downstream cleanup would be the wrong layer. |
|
Merged via squash.
|
AI-assisted: Yes. The implementation and validation used AI coding tools, with a clean final autoreview.
What Problem This Solves
Fixes an issue where QA flows that stage packaged authentication before launching an isolated Gateway could hang until their outer test timeout. The reserved Gateway port accepted an internal probe connection, and release then waited indefinitely before the real Gateway process was spawned. This surfaced in the real Gateway/node MCP stress suite as a 180-second timeout and an orphaned fixture process.
Why This Change Was Made
The port-reservation owner now immediately closes any probe connection while continuing to hold the bind address through staging. Socket creation remains at the existing Gateway-child network boundary, while release stays idempotent and occurs immediately before the real Gateway bind.
User Impact
There is no production runtime or user-visible behavior change. QA Gateway launches no longer deadlock when staged CLI work probes the reserved port, so real-process integration tests fail or proceed at their actual product boundary instead of timing out before Gateway startup.
Evidence
gateway-node-mcp.stress.e2e.test.tsexhausted its 180-second test budget; the preserved QA root had completed both auth writes but had empty Gateway logs, proving no Gateway child was spawned.Expected: "released"/Received: "probe remained open and release stayed pending".node scripts/run-vitest.mjs extensions/qa-lab/src/gateway-port-reservation.test.ts— 2/2 passed on final head.node scripts/run-vitest.mjs extensions/qa-lab/src/gateway-child.test.ts— 87/87 passed on final head.node scripts/check-changed.mjs -- extensions/qa-lab/src/gateway-port-reservation.ts extensions/qa-lab/src/gateway-port-reservation.test.ts extensions/qa-lab/src/gateway-child.ts— passed on final head.node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/gateway-node-mcp.stress.e2e.test.ts— passed on final head in 26.80 seconds; transport recovery, stateful expiry, and descendant cleanup assertions all completed.node:netimport into the helper and correctly triggered the network-runtime boundary scanner. The final head keeps socket construction in the already-classified Gateway owner while the helper owns connection rejection; focused proof and autoreview were rerun after that refinement.Production LOC: +5/-3 (net +2), justified by the lifecycle invariant that accepted probes cannot block reservation release. Tests: +26/-1.