Repository navigation
fix: fail pending Gateway requests promptly after transport loss - #2079
Conversation
Invalidate every current listen-loop loss once and fence health recovery to its captured socket. Keep loss notifications outside the publication lock and preserve cancellation of the lost node invocation snapshot. Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR centralizes transport-loss cleanup and binds delayed health recovery to its original connection. Example: A connected client aborts its socket while wizard.next has a 10,000 ms deadline.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this collaborator-authored PR repairs a verified defect still present on main, and inspection found no actionable introduced bugs. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared WebSocket transport connects operator requests and Windows node invocations to the Gateway; its loss hooks invalidate operator state and cancel affected node work. flowchart LR
A[Operator requests] --> B[Gateway client]
C[Node invocations] --> D[Windows node client]
B --> E[Shared WebSocket transport]
D --> E
E --> F[Gateway]
E --> G[Generation fenced loss cleanup]
Technical reviewBest possible solution: Land the focused repair in the existing transport, request and cancellation owners after the declared validation gates complete. Do we have a high-confidence way to reproduce the issue? Main source establishes the skipped cleanup and unowned health retry, and the author supplies baseline regression failures plus current-head loopback output; this read-only review ran no target code. Is this the best way to solve the issue? The patch is a suitably small complete repair: it keeps one loss owner, preserves request-specific exception contracts and recovery policy, and separates cancellation capture from callback execution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e70292487958. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 8, 2026, 3:12 AM ET / 08:12 UTC. |
|
Hi @karkarl! I'm a Copilot triage bot posting for Scott (I'm not Scott). He asked me to assign this PR to you and see if you'd be up for reviewing it and merging it when you're happy with it. This is one of five small fixes from the state machine audit in #2071 (Fix dangerous implicit state machines (audit lanes)). This one makes pending Gateway requests fail right away when the connection drops, instead of waiting for their timeouts, and stops a late health check from replacing a newer connection. CI note: the UI test job is red only on the known wizard "More" button baseline failure, which isn't related to this change. The real WSL Gateway jobs passed. MXC proof was skipped, so that part is still unverified. No rush at all, and please feel free to ask for changes or push back. Thank you so much! |
PR cleanup reviewReviewed head: Source cleanup review at 2b2da5d against main e59374c: the once-per-generation transport-loss notification and captured invocation cancellation are not superseded. This PR now conflicts in WindowsNodeClient.cs with the landed file-transfer work (#2028 (feat: support Sandbox-backed Windows file transfers)), so reconciliation must preserve that current owner. The loopback proof is useful, but strict Windows/WSL/MXC proof is still marked unverified and current UI/CI Gate fails. Keep this for a dedicated transport/concurrency review rather than automatic cleanup landing. Action in this cleanup pass: leaving this PR open. No branch changes or runtime-proof waiver. The findings above come from source, discussion and recorded-CI review; Windows validation was not rerun in this pass. |
|
Hi! I'm a Copilot triage agent posting for Scott (I'm not Scott). I was doing a landing pass and tried this PR against the current Where it stands
Why the conflict is more than textual
A resolution that looks like it fits this PR's contract (the author's call, I have not applied it)
Not verified
This is assigned to Karen, so I'm leaving it with her. Happy to help with the merge if that's useful. |
Preserve generation-scoped transport-loss cleanup alongside file invocation cancellation, progress receipt draining, and host statistics shutdown. Co-authored-by: bkudiess <[email protected]>
Maintainer patch on openclaw#2079 for two regressions found in review: - A throwing status subscriber, loss hook or capability cancellation callback escaped the listen loop's finally and skipped auto-reconnect and the remaining node cleanup. Each loss step now runs separately and logs only the step and exception types, so file-channel aborts, the progress drain, status delivery and reconnect still run. - A client-initiated abort newly raised Disconnected. Setup treats that as failure, so a quiet connect-send retry failed node setup. Cleanup still runs for aborted generations, but the caller keeps its existing Error or quiet-retry status, as on main. Co-authored-by: Copilot App <[email protected]>
The new timing-pattern guard on main rejects literal 2-6 s hang guards. Replace the three 5 s waits added by this PR with the existing OPENCLAW_TEST_GATEWAY_STEP_TIMEOUT_SECONDS step timeout. Co-authored-by: Copilot App <[email protected]>
…r's accepted count before it records the new socket (#2211) OpenClawGatewayClientTests.CheckHealth_StaleRecoveryCannotReplaceNewerSocket (added in #2079, "transport loss fails pending requests") failed once on main with "Expected: 2, Actual: 1" at its accepted-socket count. The product held: the newer socket was open, its generation and session key were unchanged, and no reconnect was authorized. The loopback test server records a socket only after AcceptWebSocketAsync has sent 101, on a thread-pool continuation, so the client's ConnectAsync can return before the count includes it. - Wait for the expected count with the server's existing WaitForAcceptedCountAsync (bounded by the named StepTimeout), as the file's other accepted-count checks do, then keep the exact-count assertion so an extra stale-recovery socket still fails. Co-authored-by: Copilot App <[email protected]>
Closes #2074 (Run disconnect cleanup on every gateway connection loss). Transport-loss lane of #2071 (Fix dangerous implicit state machines (audit lanes)).
What Problem This Solves
Fixes pending Gateway requests waiting for their timeout and stale connection information remaining visible when the client aborts a socket or receives an oversized message.
User Impact
User impact: requests fail promptly after transport loss, and delayed health recovery cannot replace a newer open connection. Current-head CI is blocked by a known baseline wizard rendering defect; real WSL Gateway lanes passed, but MXC proof remains skipped/unverified.
Why This Change Was Made
All current listen-loop loss paths share generation-fenced invalidation. Invalidation and cancellation capture are serialized with socket publication, but events and cancellation callbacks run outside that lock. Health recovery captures and rechecks its socket owner, including an initially disconnected client. Existing pairing, shutdown, backoff and failed/closing-socket recovery policy stay intact; Windows session-ending behavior is not changed.
Evidence
Six transport regressions failed against unchanged production code at
e70292487958be9e70170e2f3affe7afc42056e8. A review-discovered callback lock inversion was also reproduced failing, then fixed. Final focused suites pass 544/544, including live node transport-loss cancellation and a cancellation-snapshot regression.Independent shared Codex review (P0-P3) and independent Copilot rubber-duck review were performed. The latter found the callback deadlock and null-owner disposal race; both were repaired and the repair independently reviewed with no P0/P1/P2 findings. One pre-existing P3 check-then-callback race in the direct node
OnErrorhook is retained to preserve its existing contract; this PR does not claim to eliminate all lifecycle races. The reviews are static assessments, not runtime proof.Current-head CI triage (2026-11-08): Build and Test run 42460930325, attempt 1 completed with failure at head
2b2da5dc61a5028a863bca748c63364606d818f9. The UI job has one failure:NativeSharedFlowTests.NativeFallback_GatewayMoreRejectsAnOverlappingContinue,Timed out waiting for Gateway More button loaded. field=null, page.IsLoaded=True. Stack:TestSupport.WaitForRenderedConditionAsync:118->NativeSharedFlowTests:804->WithNativeAsync:547/553->UIThreadFixture:181/165. It fails before the More click or overlappingwizard.nextcall. This exact missing-control defect is recorded in docs/CI_FAILURES.md, reproduced 3/3 on pristinemain4cbbe51c. Wizard rendering, this test, its wait helper and fixture are unchanged. Classification: unrelated baseline product defect, not grounds for weakening the test or blindly rerunning. CI Gate is red because it aggregates the failed UI job. No rerun or unrelated repair performed.Change Type
Scope
winnodeRequired proof pools
windows-wsl-gateway-e2e: confirm shared transport reconnect/loss behavior with a real product WSL Gateway. Not run locally. Current-head hosted setup/connect (53 passed, 7 MXC skips), revocation recovery (1 passed) and network recovery (2 passed) lanes succeeded; this is hosted real WSL evidence, not a claim that every custom pool case ran.windows-wsl-mxc: confirm retained active-node-invocation cancellation over the real Gateway/MXC execution path. Not run locally and explicitly skipped in hosted setup/connect; no command binding, approval or sandbox policy is changed.Validation
Final source is commit
2b2da5dc61a5028a863bca748c63364606d818f9. These runs used the identical pre-commit tree, manually associated with this commit by source equality; standalone socket proof was also replayed after commit.OPENCLAW_REPO_ROOTwas set to the task worktree; opt-in integration/GPU/E2E flags were unset and Tray tests used isolated profile data. TRX logging/results-directory options accompanied the test commands..\build.ps1: passed all five projects (Shared, Cli, WinNodeCli, SetupEngine, WinUI), Debugwin-x64; documentation validation passed.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 4,883 passed, 0 failed, 24 ordinary opt-in skips, 4,907 total.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 5,294 passed, 0 failed/skipped. The fresh-worktree first run restored/built the test project before this required rerun.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter 'FullyQualifiedName~WebSocketClientBaseTests|FullyQualifiedName~OpenClawGatewayClientTests|FullyQualifiedName~InvocationCancellationRegistryTests|FullyQualifiedName~WindowsNodeClient': 544 passed, 0 failed/skipped.git diff --check: passed..\scripts\validate-mxc-e2e.ps1: not run. Provisioning/installing a real Gateway is outside this lane's runtime authority. Hosted MXC tests explicitly skipped because the runner was not opted in as MXC-capable.Current-head hosted run 42460930325 attempt 1: Core/CLI, Tray/setup/integration, fast validation, proof-pool contracts and all three WSL E2E jobs passed. UI test selection: 652 passed, 1 failed, 7 skipped (660 total); functional UI: 19 passed; accessibility: 21 passed, 13 skipped. CI Gate failed solely due to the UI job. The single failure and unrelated-baseline attribution are detailed in Evidence; overall CI is not green.
Real Behavior Proof
2b2da5dc61a5028a863bca748c63364606d818f9.dotnet run --project <session-artifacts>\transport-proof\TransportProof.csproj; perform realconnect.challenge-> signedconnect->hello-ok, then (1) withholdwizard.nextand abort the client transport, (2) start health backoff at generation zero, explicitly connect, finish the old health task and send health on the retained live socket.Yes/No/N/A): N/A for private loopback artifacts. Hosted run/job links and final job/log results were verified; private session artifacts are not public links.Security Impact
Yes/No): NoYes/No): NoYes/No): No. Existing health/reconnect calls are owner-fenced; no new endpoint or wire operation.Yes/No): No. Existing node invocation cancellation is captured before publication and executed outside the lock.Yes/No): NoYes, explain the risk and mitigation: N/ACompatibility and Migration
Yes/No): Yes for the shipped client and Gateway wire contract.Yes/No): NoYes/No): NoReview Conversations