Skip to content

Alessandro/auto reconnect server side - #5788

Open
aasoni wants to merge 4 commits into
masterfrom
alessandro/auto-reconnect-server-side
Open

Alessandro/auto reconnect server side#5788
aasoni wants to merge 4 commits into
masterfrom
alessandro/auto-reconnect-server-side

Conversation

@aasoni

@aasoni aasoni commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

Auto-Reconnect: Connection replacement and batch subscribe

Adds the two server-side changes needed for SDK auto-reconnect (proposal 0037).

Connection replacement: a client which reconnects can now send a stable, client-generated session_id query parameter. Each connection still gets its own ConnectionId and its own lifecycle events. The session id only identifies which earlier connection a new one supersedes. When a connection claims a session held by a live connection of the same identity, that connection's actor is stopped and its module-side disconnect lifecycle is awaited before the new connection's client_connected, so a module never observes two live connections for one session, nor the old connection's client_disconnected after the new client_connected.

Batch subscribe: SubscribeBatch and SubscribeBatchApplied register multiple query sets under one subscription-manager lock and evaluate them at a single transaction snapshot. No transaction update can interleave with the responses, so a reconnecting client can replay its subscriptions and reconcile its cache against a consistent snapshot. Per-set errors are reported in the response and the remaining sets still apply.

API and ABI breaking changes

No API breaking change. New V3 websocket protocol message. New clients will not be able to send this to old servers.

Expected complexity level and risk

2

Testing

  • Smoketests to test superseded connections

aasoni added 4 commits August 24, 2026 17:11
Adds the two server-side changes needed for SDK auto-reconnect
(proposal 0037).

Connection replacement: a client which reconnects can now send a stable,
client-generated `session_id` query parameter. Each connection still
gets its own ConnectionId and its own lifecycle events. The session id
only identifies which earlier connection a new one supersedes. When a
connection claims a session held by a live connection of the same
identity, that connection's actor is stopped and its module-side
disconnect lifecycle is awaited before the new connection's client_connected,
so a module never observes two live connections for one session, nor the
old connection's client_disconnected after the new client_connected.

Batch subscribe: SubscribeBatch and SubscribeBatchApplied register
multiple query sets under one subscription-manager lock and evaluate
them at a single transaction snapshot. No transaction update can
interleave with the responses, so a reconnecting client can replay its
subscriptions and reconcile its cache against a consistent snapshot.
Per-set errors are reported in the response and the remaining sets still
apply.
Adds a raw v3 websocket client to the smoketests so a test controls
exactly which query parameters a connection sends, plus a
connection-session module which logs the lifecycle reducers with their
connection ids so ordering can be asserted.

Covers:
 - a reconnect with the same session id supersedes the previous
connection, with client_disconnected for the old connection strictly
before client_connected for the new one
 - a different session id does not supersede
 - a connection without a session id is never superseded
 - repeated reconnects leave exactly one live connection
 - batch subscribe applies every set atomically, reporting per-set errors while
the remaining sets still apply.

Note that a superseded connection is stopped but is not sent a close
frame, so its peer's socket stays half-open: a passive read hangs while
a round-trip fails. The tests assert the round-trip, which is the
guarantee the server actually makes.
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