-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
Hi,
While debugging, I've noticed the db.statusStream has a large # of contiguous duplicate SyncStatus messages.
Usually ~70% of all messages are duplicates.
The logging code:
db.statusStream.listen((syncStatus) {
log.finest('statusStream: $syncStatus');
});Often produces a series of duplicate messages (note the following 3 duplicates even occur within the same millisecond timestamp):
[2:4:26.279] [powersync_endpoint] FINEST: statusStream: SyncStatus<connected: true connecting: false downloading: true uploading: false lastSyncedAt: 2025-01-04 02:04:26.098549, hasSynced: true, error: null>
[2:4:26.279] [powersync_endpoint] FINEST: statusStream: SyncStatus<connected: true connecting: false downloading: true uploading: false lastSyncedAt: 2025-01-04 02:04:26.098549, hasSynced: true, error: null>
[2:4:26.279] [powersync_endpoint] FINEST: statusStream: SyncStatus<connected: true connecting: false downloading: true uploading: false lastSyncedAt: 2025-01-04 02:04:26.098549, hasSynced: true, error: null>
To quantify the amount of duplication:
int distinctSyncStatus = 0;
int totalSyncStatus = 0;
db.statusStream.distinct().listen((syncStatus) {
distinctSyncStatus++;
log.finest('distinctSyncStatus: $distinctSyncStatus');
});
db.statusStream.listen((syncStatus) {
totalSyncStatus++;
log.finest('totalSyncStatus: $totalSyncStatus');
});Produces typical output of:
distinctSyncStatus: 1675
...
totalSyncStatus: 6230
It seems like any de-duping of the db.statusStream should be done in the library vs the client application:
- avoid overhead of:
- sending duplicate messages to client application
- de-duping in the client application
- reactive UI/behavior/functionality being unnecessarily re-triggered in the client application
- and maybe other behavior/functionality at the library level is listening to the stream and duplicating work?
Note that this does not affect correctness and may not be considered a bug.
Feel free to close if so, or concerns re overhead are misplaced, a bit OCD :)
Thanks.
Metadata
Metadata
Assignees
Labels
No labels