bug: /sync with full_state=true and since returns no rooms when nothing changed #2390

Closed
opened 2026-10-20 20:57:39 +00:00 by mspnr · 3 comments

What is the bug?

If I call /sync with full_state=true and a since token, and nothing has happened in my rooms since that token, rooms.join comes back empty even though the account is joined to rooms. As far as I understand the spec, full_state=true should return all joined rooms in this case. After a restart, Home Assistant's Matrix integration (matrix-nio) then believes it is in no rooms and refuses to load.

I have a one-line fix and will open a PR.

Steps to reproduce

  1. GET /sync?timeout=0&full_state=true with no since: rooms are returned. Note next_batch.
  2. GET /sync?timeout=0&full_state=true&since=<next_batch> with nothing new in between: rooms.join is empty.

Server name and version

private 26.8.1 (also reproduced on 26.9.1)

Additional context

No response

### What is the bug? If I call /sync with full_state=true and a since token, and nothing has happened in my rooms since that token, rooms.join comes back empty even though the account is joined to rooms. As far as I understand the spec, full_state=true should return all joined rooms in this case. After a restart, Home Assistant's Matrix integration (matrix-nio) then believes it is in no rooms and refuses to load. I have a one-line fix and will open a PR. ### Steps to reproduce 1. GET /sync?timeout=0&full_state=true with no since: rooms are returned. Note next_batch. 2. GET /sync?timeout=0&full_state=true&since=<next_batch> with nothing new in between: rooms.join is empty. ### Server name and version private 26.8.1 (also reproduced on 26.9.1) ### Additional context _No response_
Owner

This is not how sync works - the rooms will be included in rooms.join when they have new events, but with full_state=true, they will also be included with the full state before the timeline, instead of the normal delta

This is not how sync works - the rooms will be included in rooms.join when they have new events, but with `full_state=true`, they will also be included with the full `state` before the timeline, instead of the normal delta
Author

Thanks for taking a look. I appreciate the correction about how sync normally works, and I may well be misreading the spec, so here is how I got to this.

Docs: the spec describes full_state as "Controls whether to include the full state for all rooms the user is a member of", and says "all state events will be returned, even if since is non-empty" (spec). I read "all rooms" as every joined room, including ones with no new events. I'd be happy to be corrected if you read it differently.

Synapse: the reference server seems to behave that way. It loops over all joined rooms "even if there are no new events" (code), passes full_state as always_include (code), and skips its early return for empty rooms when it's set (code). Sytest also has a test called "Full state sync includes joined rooms" (test). Without full_state, quiet rooms are left out, as you describe, and the PR doesn't change that.

In practice: this breaks for me. I run Home Assistant with the matrix_extended integration, which uses matrix-nio. It saves the sync token, and after a restart it syncs with since and full_state=true. matrix-nio recommends this pattern (matrix-nio#292). On Continuwuity rooms.join comes back empty, so the client concludes it is in no rooms and fails to load.

Is there a reason you'd prefer full_state to only cover rooms with new events? For example, the cost for accounts with many rooms, or something else? If it's intentional, I'm happy to look for another approach or a different fix.

Thanks for taking a look. I appreciate the correction about how sync normally works, and I may well be misreading the spec, so here is how I got to this. **Docs:** the spec describes `full_state` as "Controls whether to include the full state for all rooms the user is a member of", and says "all state events will be returned, even if `since` is non-empty" ([spec](https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3sync)). I read "all rooms" as every joined room, including ones with no new events. I'd be happy to be corrected if you read it differently. **Synapse:** the reference server seems to behave that way. It loops over all joined rooms "even if there are no new events" ([code](https://github.com/element-hq/synapse/blob/80d50913d64dfc477be8ca5dbf7b1952f04f2773/synapse/handlers/sync.py#L3250-L3254)), passes `full_state` as `always_include` ([code](https://github.com/element-hq/synapse/blob/80d50913d64dfc477be8ca5dbf7b1952f04f2773/synapse/handlers/sync.py#L3006)), and skips its early return for empty rooms when it's set ([code](https://github.com/element-hq/synapse/blob/80d50913d64dfc477be8ca5dbf7b1952f04f2773/synapse/handlers/sync.py#L3426-L3440)). Sytest also has a test called "Full state sync includes joined rooms" ([test](https://github.com/matrix-org/sytest/blob/747315856d24eee846c6923b696fff9fae55ca0f/tests/31sync/03joined.pl#L48)). Without `full_state`, quiet rooms are left out, as you describe, and the PR doesn't change that. **In practice:** this breaks for me. I run Home Assistant with the `matrix_extended` integration, which uses matrix-nio. It saves the sync token, and after a restart it syncs with `since` and `full_state=true`. matrix-nio recommends this pattern ([matrix-nio#292](https://github.com/matrix-nio/matrix-nio/issues/292)). On Continuwuity `rooms.join` comes back empty, so the client concludes it is in no rooms and fails to load. Is there a reason you'd prefer `full_state` to only cover rooms with new events? For example, the cost for accounts with many rooms, or something else? If it's intentional, I'm happy to look for another approach or a different fix.
Owner

The current behaviour is the behaviour described in the spec, for multiple reasons including performance. There is no reference server. It is the client's job to persist state.

The current behaviour is the behaviour described in the spec, for multiple reasons including performance. There is no reference server. It is the client's job to persist state.
Jade 2026-10-20 23:14:28 +00:00
Sign in to join this conversation.
No milestone
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
continuwuation/continuwuity#2390
No description provided.