Skip to content

Support DDP session resumption (4.2.0) - #75

Open
tanutapi wants to merge 3 commits into
masterfrom
feat/ddp-session-resumption
Open

Support DDP session resumption (4.2.0)#75
tanutapi wants to merge 3 commits into
masterfrom
feat/ddp-session-resumption

Conversation

@tanutapi

@tanutapi tanutapi commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements the client side of meteor/meteor#14051 (DDP session resumption, merged 2026-03-06).
  • After an unexpected disconnect the client keeps its session id and receivedCount and sends both in connect. If the server hands the same session back, the login and subscriptions continue untouched, messages published during the gap arrive in order, and onReconnect callbacks are not run. Otherwise the reconnect behaves exactly as before (re-login, re-subscribe).
  • In-flight method calls fail with MeteorConnectionError once the reconnect completes, resumed or not: a request written just before the drop may never have reached the server, and that can't be told apart from a slow method (confirmed against a live server — keeping them pending hung forever).
  • disconnect() now sends a DDP disconnect message first so the server drops the session immediately instead of holding it for the grace period.
  • New DdpClient.resumedSession / receivedCount getters. Version bumped to 4.2.0; README and CHANGELOG updated.
  • Servers without resumption support ignore the extra fields; behaviour against them is unchanged.

Test plan

  • dart analyze clean
  • test/lifecycle_test.dart + test/ddp_mock_server_test.dart: 31/31 pass, repeated runs without flakes
  • 9 new tests: count tracking, resume without re-login/re-sub, gap messages after resume, in-flight call fails on resume, count mismatch, explicit disconnect, server-initiated close, expired grace period, old-server fallback
  • test/dart_meteor_test.dart against a live Meteor server with #14051: 30/30 pass
  • Manual probe through a TCP proxy against the live server: ungraceful cut → same session id back, resumedSession == true, subsequent calls work

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q5VJ5d285h9engGixa8Cm1

tanutapi and others added 3 commits August 21, 2026 15:54
Implements the client side of meteor/meteor#14051. After an unexpected
disconnect the client keeps its session id and message count and asks the
server to resume; when it does, login, subscriptions and in-flight method
calls carry on untouched and onReconnect callbacks are skipped. Otherwise
the reconnect falls back to the previous behaviour. disconnect() now sends
a DDP disconnect message so the server frees the session immediately.

The mock server models the new server semantics behind a
supportsResumption flag, with tests for both old and new servers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5VJ5d285h9engGixa8Cm1
Verified against a live Meteor server through a TCP proxy: a method
written to the socket just before the cut never reached the server, so a
call kept pending across a resumed session hung forever - the bug 4.1.0
fixed. The client cannot tell a lost request from a slow method, so
in-flight calls now fail with MeteorConnectionError once the reconnect
completes, resumed or not.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5VJ5d285h9engGixa8Cm1
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