fix(web): close wedged websockets with an app.version heartbeat - #1771
Merged
Merged
Conversation
A half-open socket answers nothing and never fires close, so every recovery mechanism (reconnect, hydration, subscription replay) waited forever while the UI showed stale streaming state. A 30s interval now issues the existing app.version RPC with a 10s deadline; an unanswered probe closes the socket locally and the established onclose ladder owns recovery. agent.send gains a 20s timeout so a composer submit cannot park forever on a dead socket. The wedged-socket test now answers the liveness probe, since a socket that ignores it is exactly what the watchdog closes.
This was referenced Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Previously every recovery mechanism in the client transport (reconnect scheduling, running-thread hydration, subscription resync, thread-list refresh) hung off
ws.onclose. A half-open or wedged socket never fires it, so pushes silently stopped whilerunningThreadIdskept stale state and the UI stayed in "streaming" forever.The transport now runs a liveness probe. Every 30s on an open socket it issues the existing
app.versionRPC with a 10s deadline. An unanswered probe closes the socket locally, soonclosefires and the established recovery ladder takes over.agent.sendalso gains a 20s timeout so a composer submit errors instead of parking inpendingforever.Why
Composer and project tree could report a thread as active/streaming while the socket had silently died. No ping/pong or application heartbeat existed anywhere in the transport, so nothing could trigger recovery for a dead-but-open connection.
Evidence
src/__tests__/connection.test.ts: silent socket is closed and reportsreconnectingafter one interval plus the timeout; an answered heartbeat leaves the socket open.src/transportsuite: the wedged-socket premise had to acknowledge the probe, which is itself the fix working. 69 transport tests pass;tsc --noEmitclean forapps/web.Review notes
This is PR 1 of a stacked series finishing the
agent.eventtoagent.canonicalruntime migration. The plan lives atdocs/plans/canonical-runtime-state-migration.md(gitignored working doc). Live lanes and perf probes per the plan are still outstanding.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.