perf(llc): skip replaying oversized /sync payloads - #2934
Draft
xsahil03x wants to merge 1 commit into
Draft
Conversation
Replaying a large `/sync` payload through `handleEvent` holds local persistence and state updates long enough to slow down the regular requests that need them. Payloads over 250 events are no longer replayed. On reconnect the synced channels are re-queried in their place, a page at a time, and `lastSyncAt` only advances once that refresh succeeded — dropping the events is safe when their state has been re-fetched, but advancing past a failed refresh would lose them. Mark-all-read events are still applied, since a channel refresh does not carry read state. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Replaying a large
/syncpayload throughhandleEventholds local persistence and state updates long enough to slow down the regular requests that need them. Payloads over 250 events are no longer replayed — the synced channels are re-queried in their place.Implements the Sync events limit spec, matching
stream-chat-swift(SyncRepository) andstream-chat-android(SyncManager), which use the same 250-event threshold.Ticket: FLU-756
What changed
StreamChatClient.syncskips event replay when a/syncresponse carries more than 250 events.queryChannelsin their place, one 30-channel page at a time (the server returns at most 30 channels per request, so a single query would silently cover only the first page).lastSyncAtadvances only once that refresh succeeded. Dropping the events is safe when their state has been re-fetched; advancing past a failed refresh would lose them.lastSyncAtfallbacks now useDateTime.timestamp()instead of local time.Behavior change worth a second look
On reconnect, the re-query after a skipped replay runs even when
recoverStateOnReconnectisfalse(whichStreamChatCoresets for every app built onstream_chat_flutter). Skipping replay drops in-memory channel state, so without it there is nothing to repair the currently open channel. When the refresh does run, the flag's own re-query is skipped so the channels are not queried twice.A direct
client.sync()call issues no queries — only the reconnect path opts into the refresh.Verification
dart analyze --fatal-infos,dart format, and the fullstream_chatsuite (1632 tests) pass. New tests cover the skip, the re-query in its place, page batching past 30 channels,lastSyncAtbeing kept when the refresh fails, and mark-all-read surviving the skip.