Skip to content

fix(test): Gateway e2e connect times out before the Gateway's own handshake deadline on loaded runners - #169479

Merged
RomneyDa merged 1 commit into
mainfrom
fix/codex-catalog-gateway-connect-timeout
Oct 12, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/codex-catalog-gateway-connect-timeout

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: Gateway e2e tests fail with gateway connect timeout when the connect handshake to a just-started test Gateway takes more than 10s on a loaded runner. Seen in release validation for 2026.10.5-beta.2 (test/plugins/codex-model-catalog.gateway.test.ts, job 114606058874, hosted ubuntu-24.04, 4 cores, workers=2).

User Impact

No user-visible change; this is test-only. Gateway e2e fixtures stop failing on slow handshakes that the Gateway itself still accepts.

Why This Change Was Made

connectGatewayClient (used by startGatewayWithClient) gave up after a fixed 10s. The Gateway's own preauth handshake deadline is 15s (DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS, overridable by OPENCLAW_HANDSHAKE_TIMEOUT_MS/OPENCLAW_TEST_HANDSHAKE_TIMEOUT_MS), and the client's challenge watchdog is aligned to that same deadline. So the fixture raced the product with a shorter timer and reported a handshake the Gateway would still complete as a failure. The fixture now defaults to the resolved server deadline plus 5s of grace. A real stall therefore surfaces as the Gateway's or client's own verdict (handshake close or challenge timeout, with phase and elapsed time), not the fixture's anonymous timer. Explicit timeoutMs callers are unchanged.

This is not a product bug. The failing test spent about 30s in startGatewayServer on the hosted runner, then more than 10s in connect. Locally, phase probes put the full handshake at 250–350ms (warm, cold transform cache, and 4 concurrent copies), with at most 14ms of event-loop delay and no wait in prepareMembership. The CI stall is load on the hosted runner, not a handshake that never finishes. The "gateway token mismatch" line in the same job log comes from gateway-cli-plugin-routing.test.ts's intentional wrong-token case and is unrelated.

Evidence

  • Reproduced the CI failure mode by temporarily delaying hello by 12s (inside the server's 15s window). On main, pnpm test test/plugins/codex-model-catalog.gateway.test.ts --maxWorkers=1 fails with Error: gateway connect timeout. With this change, it passes. The delay injection was not committed.
  • Unmodified with this change: pnpm test test/plugins/codex-model-catalog.gateway.test.ts --maxWorkers=1 passes (97s wall on a heavily loaded host; Vitest duration 42s). No new or changed test files.
  • Fixture siblings src/gateway/gateway-cli-plugin-routing.test.ts and src/gateway/server.shared-auth-rotation.test.ts pass. oxlint, oxfmt --check, and git diff --check are clean.
  • Gap: the hosted-runner stall itself was not reproduced locally, so its exact length is unknown. The new budget covers stalls up to the Gateway's own deadline; anything longer now fails with the product's handshake-timeout diagnostics.

Inherited CI failures (run 38188111637)

openclaw/ci-gate is red only because 7 checks-node-changed-* jobs failed. The change-based selector picked them because this file is imported by many gateway e2e suites. Every failing case also fails locally on the tested merge's first parent, main 521393ecd7d (and on 0387f4f96a2), without this change. The tested merge add092a0 differs from that baseline only in src/gateway/test-helpers.e2e.ts. None of the failures is a connect timeout. They are post-connect assertions or timeouts, and this change can only lengthen the connect budget:

  • compact-large-2: server.chat-recovered-output.test.ts (2), server.xai-fallback.test.ts (expected '' to be The answer is)
  • compact-large-6: server.chat.orphaned-recovery.test.ts (history length 3 vs 2)
  • compact-large-8: gateway.chat-redaction.test.ts (2, recorded model input)
  • changed-1: gateway-workshop-learning.e2e.test.ts, gateway.models-policy-reload.e2e.test.ts
  • changed-4: gateway-rpc-chat.e2e.test.ts (history length 2 vs 1)
  • changed-5: embedded-transcript-cursor.e2e.test.ts (generation_mismatch), gateway-completion-replay.e2e.test.ts
  • changed-6: gateway-session-end-shutdown.e2e.test.ts (120s timeout)

security-fast and every other job passed.

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@RomneyDa
RomneyDa marked this pull request as ready for review October 12, 2026 00:28
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR defaults Gateway E2E client acquisition to the shared handshake deadline plus five seconds.

Example: A Gateway completes hello after 12 seconds with the default 15-second handshake deadline.

  • Before: The fixture rejects after 10 seconds.
  • After: The handshake completes within the fixture's 20-second budget.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and sound; confidence in execution rests on reported in-process validation rather than an inspectable capture.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored test-only PR is outside the ordinary product-proof gate; the body reports exercising the real fixture and Gateway with delayed hello, but attaches no execution artifact.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Maintainers encounter false Gateway connection failures during release validation on loaded runners.
Reason: The maintainer-authored repair addresses a concrete fixture mismatch with a narrow change and no product-policy expansion.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a fixture deadline mismatch still present on main, and no introduced defect was found.

Priority: P2
Reviewed head: ad90603846f4477654c1b32a2995b45f9c822423

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway E2E fixtures turn connection options into an authenticated WebSocket client, retaining acquisition ownership until successful handoff or joined cleanup.

flowchart LR
A[Gateway tests] --> B[E2E fixture]
C[Shared handshake deadline] --> B
B --> D[Client acquisition]
D --> E[Gateway handshake]
E --> F[Connected client or joined cleanup]
Loading

Technical review

Best possible solution:

Use the shared handshake deadline for the fixture budget while preserving explicit overrides and joined failure cleanup.

Do we have a high-confidence way to reproduce the issue?

Source establishes the 10-second fixture versus 15-second handshake mismatch, and the author reports a controlled 12-second before/after reproduction; no target code was run during this review.

Is this the best way to solve the issue?

The focused change reuses the authoritative resolver and fixes the fixture mismatch without changing production handshake policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 751fa4fe7652.

Provenance checked

  • Gateway E2E acquisition timeout changes intended behavior with a stated reason (de14dd3: The acquisition refactor carried forward the existing 10-second budget while preventing leaked clients; this was not the budget's original introduction.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit de14dd3 adds src/gateway/test-helpers.e2e.ts:116 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: de14dd375040; files: src/gateway/test-helpers.e2e.ts)
  • Tak Hoffman: Raw commit 0d50887 adds src/gateway/test-helpers.e2e.ts:101 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 0d508879d14d; files: src/gateway/test-helpers.e2e.ts)
  • Vincent Koc: Raw commit 7bdca7d adds src/gateway/test-helpers.e2e.ts:134 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 7bdca7d8d1bb; files: src/gateway/test-helpers.e2e.ts)

PR surface

Source +3. Total +3 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 4 1 +3

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: False connection failures disrupt release validation on loaded runners without changing application runtime behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-12T00:39:43.543Z sha ad90603 :: needs changes before merge. :: none

Reviewed October 11, 2026, 9:19 PM ET / October 12, 2026, 01:19 UTC (Revision 2).

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
@RomneyDa
RomneyDa merged commit e482290 into main Oct 12, 2026
213 of 223 checks passed
@RomneyDa
RomneyDa deleted the fix/codex-catalog-gateway-connect-timeout branch October 12, 2026 02:35
RomneyDa added a commit that referenced this pull request Oct 12, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
RomneyDa added a commit that referenced this pull request Oct 15, 2026
RomneyDa added a commit that referenced this pull request Oct 15, 2026
…solation, and flake fixes from main (#172693)

* fix(context-engine): stop re-logging terminal blocked turns on every run

Backport of #167595 (be39fa3) to the 2026.9.33 outbox owner, which
still lives in context-engine-turn-outbox.ts on this line.

* test(agents): retire session MCP managers left by earlier test files (#172515)

(cherry picked from commit d4be691)

* test(ci): bound native declaration fixture libraries

Use ES5 ambient libraries for the synthetic native preparation programs
instead of loading the default ES2023/browser library graph on every
preparation. Keep the ES2023 syntax target, real native compiler, seven
plugin producers, six preparation calls, both compiler failure controls,
all assertions, and every existing timeout unchanged.

The oversized fixture configuration originated in b78612a. The
original ten-file shard reproduces the 30-second repair-case timeout on
two CPUs and two workers. With the fixture scoped to its required built-ins,
the same shard passes twice: 163 passed, four platform skips, and repair
case times of 23.292s and 23.555s (303.26s and 304.25s shard wall times).

Focused remote proof: pnpm test
test/scripts/prepare-extension-package-boundary-artifacts.native.test.ts
--maxWorkers=1 passes 15 tests with three Windows skips in 77.39s wall time
on two CPUs. No production code, assertion, retry, or deadline changes.

Changed checks pass formatting, ratchets, and all four test-root type shards.
The broader namespace-export scan flags the unchanged model-catalog.runtime
barrel on the pinned base; upstream ece9d9c already removes that export.

(cherry picked from commit 05179a7)

* fix(test): prevent Wear reader leaks between test cases (#172075)

* fix(test): prevent resource leaks and cold-build shutdown timeouts

* fix(test): include the worker bootstrap in the PR wrapper inventory

(cherry picked from commit 03b02ee)

* test(gateway): wait past the server handshake deadline in Gateway e2e connects (#169479)

(cherry picked from commit e482290)

* fix(test): managed-process, Vitest shutdown, and worker-artifact tooling tests time out on loaded hosts while polling ready files (#162613)

Test-tooling suites for the managed child-process runner, check-changed cancellation, Vitest fork/worker shutdown, worker artifacts, and run-vitest progress waited for fixture wrappers, workers, and descendants by polling ready files, PID files, and the process table against 1-15 s wall-clock deadlines, which a loaded host outlasts.

Readiness now arrives on the owned channel each fixture already has: runManagedCommand's onReady stream and child events, stdout/IPC readiness written after the fact it announces (PID files are renamed into place first), relayed worker readiness for the Vitest fork/worker fixtures, and retained command outcomes that fail fast if the child settles first. Foreign-descendant extinction without an owner join keeps a deadline-free check bound to the test signal. check-changed-cancellation and run-vitest-progress drop out of the timeout-race baseline. The reverse-release wait in run-vitest-progress and the native Windows Job cases stay unchanged (follow-ups; the latter has no native CI execution). No product source, test timeout, product timeout, or assertion meaning changed.

Part of the polling audit from #162274. Proof on Blacksmith Testbox: delayed-readiness fault probes fail the original bytes and pass these bytes; forced-abort probes reach cleanup; 20/20 standalone runs per file; 3/3 replays of all seven owning tooling shards on the rebased head; tsgo; Codex autoreview and ClawSweeper clean.

(cherry picked from commit b9512e7)

* test: stabilize release timing boundaries (#166218)

(cherry picked from commit 69ccd1e)

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant