From 3debaff0f86c1f34d5c5970bd5a10bea8a67b266 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Fri, 21 Aug 2026 18:56:03 +0300 Subject: [PATCH] Fix `__len__` of Sliding Sync `PerConnectionState` ignoring account data (#20124) Noticed while working on https://github.com/element-hq/synapse/pull/20003, submitting separately. ### Pull Request Checklist * [x] Pull request is based on the develop branch * [x] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should: - Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.". - Use markdown where necessary, mostly for `code blocks`. - End with either a period (.) or an exclamation mark (!). - Start with a capital letter. - Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry. * [x] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct (run the [linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters)) --------- Co-authored-by: Eric Eastwood --- changelog.d/20124.misc | 1 + synapse/types/handlers/sliding_sync.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20124.misc diff --git a/changelog.d/20124.misc b/changelog.d/20124.misc new file mode 100644 index 0000000000..d92a12ce08 --- /dev/null +++ b/changelog.d/20124.misc @@ -0,0 +1 @@ +Fix cache `__len__` of Sliding Sync `PerConnectionState` ignoring account data entries. \ No newline at end of file diff --git a/synapse/types/handlers/sliding_sync.py b/synapse/types/handlers/sliding_sync.py index dd913250ba..d8c90c0fdd 100644 --- a/synapse/types/handlers/sliding_sync.py +++ b/synapse/types/handlers/sliding_sync.py @@ -919,6 +919,7 @@ class PerConnectionState: receipts: The status of each room for the receipts stream. room_configs: Map from room_id to the `RoomSyncConfig` of all rooms that we have previously sent down. + account_data: The status of each room for the account_data stream. """ last_used_ts: int | None = None @@ -951,7 +952,12 @@ class PerConnectionState: ) def __len__(self) -> int: - return len(self.rooms) + len(self.receipts) + len(self.room_configs) + return ( + len(self.account_data) + + len(self.rooms) + + len(self.receipts) + + len(self.room_configs) + ) @attr.s(auto_attribs=True)