[BUG]:- Redundant Sync Re-initialization & Subscription Overlap in sync.ts
#190
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A structural flaw in
src/app/core/sync.tscauses the entire synchronization state for a Space to be torn down and restarted whenever a user navigates between rooms. Additionally, overlapping subscriptions result in duplicate network traffic for every event.Root Cause
syncSpacesstore subscription includes$page.params.hin its key derivation. Changing rooms alters theroomsKey, which callsunsubscriber()to abort all active connections for the space before immediately restarting them.syncSpaceinitializes a relay-wide listener for content kinds while simultaneously spawning dedicated per-room listeners for those same kinds. This results in every message being requested and processed twice.Impact
CLOSE/REQcycles on every navigation.Suggested Fix
$page-dependent space sync.@hodlbod can i work on this!!
The redundancy in syncSpace is by design, some relay implementations are picky and won't respond to filters without an
htag. If the relay supports negentropy, it mostly prevents duplicate syncing, although you're right that there are multiple listeners.You're right that the page sync is redundant and harmful. In an effort to understand it I came up with this patch:
9f386f69If there's anything else that needs to be done let me know, and feel free to open a PR.
No additional changes needed from this patch 9f386f69
@hodlbod
Great, thanks!