Repository navigation
fix(connection): a frozen Gateway goes unnoticed while TCP stays open - #1962
Conversation
Worked on by: - @MertBasar0 Co-authored-by: MertBasar0 <[email protected]> OpenClaw-Publication: 7c692efe-bf23-4b71-91ab-8beb4e088c1c
|
🦞👀 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: needs maintainer review before merge. What this changesThis PR adds WebSocket ping timeouts and reports unexpected timeout cancellation as a disconnect before reconnecting. Example: A Gateway stops responding while its TCP connection remains open.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a concrete liveness defect still present on main, with a focused implementation and no definite introduced code defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherWebSocketClientBase owns transport lifecycle for both operator and Windows node clients, converting received frames and socket failures into message handling, connection status, cleanup, and authorized reconnect attempts. flowchart LR
Gateway[Gateway WebSocket peer] --> Transport[WebSocketClientBase]
Transport --> Operator[Operator client]
Transport --> Node[Windows node client]
Transport --> Cleanup[Disconnect cleanup]
Cleanup --> Recovery[Existing reconnect authorization and backoff]
Technical reviewBest possible solution: Keep bounded protocol liveness and generation-scoped disconnect cleanup in WebSocketClientBase while preserving intentional aborts and existing reconnect authorization. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the missing response deadline, and MertBasar0 supplies before/after real-client traces against a frozen ws peer; this read-only review ran no reproduction, build, or tests. Is this the best way to solve the issue? A finite protocol timeout addresses the missing liveness check in the shared owner, with generation-scoped abort tracking preserving silent intentional recovery and distinct tests supporting each changed boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a4dd026cc5f8. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
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 October 31, 2026, 8:31 PM ET / November 1, 2026, 00:31 UTC. |
Closes #1958
Prepared by @MertBasar0 (Discord: mertinGo). The Windows validation and measurements below were performed by MertBasar0 on the original candidate; this PR republishes the identical source change.
What Problem This Solves
Fixes: Companion stays connected to a Gateway that has stopped responding, for as long as its TCP connection stays open.
User Impact
User impact: when the peer stops answering, Companion reports the connection as lost and reconnects within about 60 seconds instead of waiting indefinitely.
Behavior to review, two ways a healthy connection can now be dropped:
wslibrary on the Gateway's event loop, so an event loop blocked for 30 seconds now causes a reconnect.Task.Run, so I expect handlers to stay well under 30 seconds. I did not measure real handler times. If a handler can block that long, the fix is to move it out of the receive loop or raise the timeout.Why This Change Was Made
WebSocketClientBasesetKeepAliveIntervaland leftKeepAliveTimeoutunset, so .NET only sent unsolicited pongs and never expected an answer. 30 + 30 seconds matches the main repo client's limit of two 30-second ticks.Setting the timeout alone was not enough. When the pong is missing, .NET aborts the socket and the pending receive throws
OperationCanceledException, which the listen loop treated as a shutdown: it reconnected without callingOnDisconnectedor reportingDisconnected. The first measurement of this change showed exactly that. The loop now separates that case from_ctscancellation and fromAbortCurrentWebSocket, which keeps its silent reconnect.Evidence
A Node server using
[email protected]with automatic pongs, which blocks its event loop 75 seconds after connecting. The client is the realWebSocketClientBasewith production values.a4dd026values)Disconnected, thenConnecting, 67 seconds after the freezeconnected=TrueChange Type
Scope
winnodeRequired proof pools
windows-wsl-gateway-e2e: connection recovery changed. Not run here.Validation
Run on
a4dd026plus this change. Windows 11 x64 build 26200, tr-TR, .NET SDK 10.0.402../build.ps1: succeeded.ExecReusableCommandBinderTests.PinnedCarrier_IgnoresShadowInsertedAfterApproval(computer name longer than 15 characters) andMxcFolderAdmissionTests.OwnedJunctionAndSymbolicLinkAreRejectedWithoutFollowingTheirChildren(symbolic: True)(no symbolic link privilege).OPENCLAW_TRAY_*directories isolated: 4799 passed, 0 failed.StoreMigrationPackagePresenceTests.DeletedReceipt_WithoutStorePackage_ReportsNoMigration(removeDirectory: False)and twoMigrationRecordTests.WindowsPowerShellChecker_UsesTheSameContractcases.KeepAlive_PeerStopsAnsweringPings_ReconnectsOnFreshSockettimes out withoutKeepAliveTimeout, and fails on the missingDisconnectedwithout the listen loop change.KeepAlive_PeerAnswersPings_KeepsTheConnectionpasses in all three states.AbortCurrentWebSocket_PreventsLaterMessagesOnAcceptedSocketnow also asserts that a client abort stays silent.Real Behavior Proof
[email protected]on loopback.a4dd026plus this change. CI on the PR head is the current-head result.TestWebSocketClientwith the production keep-alive values and log each status change with its time. Repeated withKeepAliveTimeoutnot set.Yes/No/N/A): N/ASecurity Impact
No)No)No)No)No)Yes, explain the risk and mitigation:Compatibility and Migration
Yes)No)No)Review Conversations
Worked on by