Remove eager full sync from RemoteEventsList#67
Merged
Conversation
The constructor was eagerly calling doFullSync() which paginated through ALL events (100 per page) on every conversation load. This caused a flood of search?limit=100 requests even though the UI only needs the last 10 events initially and uses WebSocket for new events. Now doFullSync() is only triggered when getEvents() or ensureSynced() is explicitly called, which the conversations UI never does. Co-authored-by: openhands <openhands@all-hands.dev>
This reverts commit 1e505fa.
The constructor was firing a doFullSync() that paginated through ALL events (limit=100 per page) on every instantiation — even when no caller ever used the cache-backed methods (getEvents, getEvent, length, asyncIterator). The only production consumer (the conversations UI) exclusively uses .search() which hits the API directly, so the sync was pure waste. Changes: - Remove doFullSync(), syncPromise, ensureSynced(), and the AsyncLock from RemoteEventsList - Make getEvents() fetch from the server on demand instead of reading from a pre-populated cache, merging in any WebSocket-delivered events not yet persisted server-side - addEvent() still appends to the local cache for WebSocket events Co-authored-by: openhands <openhands@all-hands.dev>
ee2931c to
ae545fd
Compare
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.
Problem
RemoteEventsListeagerly fetches all events (paginating withlimit=100) in its constructor viadoFullSync(). This fires on every conversation load — even though the only production consumer (the conversations UI) exclusively uses.search()with its own params and never touches the cache-backed methods.This means every conversation load makes a superfluous
GET /events/search?limit=100call that downloads data nobody reads.Changes
doFullSync(),syncPromise,ensureSynced(), andAsyncLockfromRemoteEventsList— the constructor no longer fires any network requestsgetEvents()now fetches from the server on-demand (same pagination logic), merging in any locally-cached WebSocket events not yet persisted server-sideaddEvent()still appends to the local cache for WebSocket eventssearch(),count(), and all other methods are unchangedWhat still works
getEvents()/ async iterator still get the full event history (fetched on demand instead of eagerly)addEvent()search()is completely unaffectedTesting
tsc --noEmitpasses