Skip to content

fix: deliver queued messages to reconnecting room server clients#2

Open
tjdownes wants to merge 2 commits intodevfrom
fix/room-server-reconnect
Open

fix: deliver queued messages to reconnecting room server clients#2
tjdownes wants to merge 2 commits intodevfrom
fix/room-server-reconnect

Conversation

@tjdownes
Copy link
Copy Markdown
Owner

@tjdownes tjdownes commented May 1, 2026

Summary

  • When a client is evicted (inactive >1 hour), last_activity is set to 0
  • Previously the sync loop permanently skipped clients with last_activity == 0, so any messages that arrived during their offline period were never delivered on reconnect
  • Fix: treat last_activity == 0 as a reconnect signal, restore the client's sync state (preserving sync_since to avoid replay, resetting push_failures and pending_ack_crc) and fall through to the normal unsynced-message fetch

Test plan

  • pytest tests/test_room_server_reconnect.py: 9 tests, all pass
  • Device test: disconnect client, send messages, reconnect: backlog delivered

tjdownes and others added 2 commits May 1, 2026 05:49
When a client (e.g. a phone-app user) disconnects and is inactive for
more than INACTIVE_CLIENT_TIMEOUT (1 hour), the eviction routine marks
their room_client_sync row with last_activity=0 and removes them from
the in-memory ACL.  Previously, when that client reconnected and was
re-added to the ACL, the sync loop would see last_activity=0 and
permanently skip them — so any messages that arrived while they were
offline were never delivered.

Fix: treat last_activity==0 as a reconnect signal rather than a
permanent skip.  The sync loop now restores the client's sync state
(preserving sync_since so already-seen messages are not replayed,
resetting push_failures and pending_ack_crc) and falls through to the
normal unsynced-message check so the backlog is delivered immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
9 tests across three classes:
- TestSyncLoopReconnect: evicted client (last_activity==0) is restored,
  sync_since is preserved, and backlog fetch proceeds
- TestSyncLoopMaxFailures: client at MAX_PUSH_FAILURES is skipped; one
  below the limit is not
- TestSyncLoopNormalClient: message fetch, push trigger, empty-client
  shortcut, and pending-ack skip

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tjdownes tjdownes closed this May 1, 2026
@tjdownes tjdownes reopened this May 1, 2026
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