fix: deliver queued messages to reconnecting room server clients#2
Open
fix: deliver queued messages to reconnecting room server clients#2
Conversation
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>
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.
Summary
last_activityis set to 0last_activity == 0, so any messages that arrived during their offline period were never delivered on reconnectlast_activity == 0as a reconnect signal, restore the client's sync state (preservingsync_sinceto avoid replay, resettingpush_failuresandpending_ack_crc) and fall through to the normal unsynced-message fetchTest plan
pytest tests/test_room_server_reconnect.py: 9 tests, all pass