Skip to content

Fix WebSocket lifecycle responsiveness#443

Open
shanselman wants to merge 1 commit into
masterfrom
shanselman/websocket-lifecycle-correctness
Open

Fix WebSocket lifecycle responsiveness#443
shanselman wants to merge 1 commit into
masterfrom
shanselman/websocket-lifecycle-correctness

Conversation

@shanselman
Copy link
Copy Markdown
Contributor

Summary

  • Serialize outbound WebSocket sends to prevent concurrent ClientWebSocket.SendAsync collisions.
  • Thread connection cancellation from GatewayConnectionManager through GatewayClientFactory into WebSocketClientBase, with captured-socket listen loops and generation guards for stale lifecycle work.
  • Move node invoke capability execution off the WebSocket receive loop using bounded observed dispatch while preserving existing response protocols.

Felt-performance/correctness risk addressed

This prevents receive loops from being blocked by long-running node capabilities, prevents fire-and-forget request sends from colliding, and avoids stale connect/reconnect work updating gateway or node state after cancellation/disconnect.

Validation

  • ./build.ps1
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
  • Additional targeted: dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj

Serialize outbound WebSocket sends, propagate connection cancellation, and move node invoke execution off the receive loop with bounded dispatch. Add regression coverage for send serialization, dispatch responsiveness, and lifecycle cancellation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant