Skip to content

Auto-reconnect (server side only) - #5877

Open
aasoni wants to merge 8 commits into
masterfrom
alessandro/refuse-takeover-for-same-session-and-teardown
Open

Auto-reconnect (server side only)#5877
aasoni wants to merge 8 commits into
masterfrom
alessandro/refuse-takeover-for-same-session-and-teardown

Conversation

@aasoni

@aasoni aasoni commented Sep 7, 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. When a client re-connects while an existing connection is still open (likely waiting on server-side idle timeout to fire) the provided session id will match an existing session. The new connection is refused, and the previous one associated with the session id is torn down. Once the old connection is fully closed the session id is freed up allowing the next reconnect attempt to claim the session. This ensures that lifecycle reducers run fully for the previous connection before a new one is established.

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.

Rollback safety impact

n/a.

Expected complexity level and risk

3 - Primarily because of the changes to connection takeover

Testing

  • Smoketests to test superseded connections

aasoni added 6 commits August 26, 2026 17:39
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
@aasoni
aasoni changed the base branch from alessandro/auto-reconnect-server-side to master September 7, 2026 12:13
@aasoni
aasoni force-pushed the alessandro/refuse-takeover-for-same-session-and-teardown branch from dc21898 to 3f9d328 Compare September 7, 2026 12:38
@aasoni
aasoni marked this pull request as draft September 7, 2026 15:13
@aasoni
aasoni marked this pull request as ready for review September 10, 2026 11:14
@aasoni aasoni changed the title Refuse connection of existing session and start teardown instead Auto-reconnect (server side only) Sep 10, 2026
@aasoni aasoni mentioned this pull request Sep 10, 2026
1 task
@aasoni
aasoni requested a review from jsdt September 10, 2026 15:40
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.

2 participants