Skip to content

Conversation

MadLittleMods
Copy link
Contributor

@MadLittleMods MadLittleMods commented Aug 18, 2022

A proposal for letting homeservers give feedback to clients where there is a gap in the timeline from a /messages response.

Spawned from a discussion with @erikjohnston about making /messages faster

Rendered

Implementations:

@MadLittleMods MadLittleMods changed the title MSCXXX: Gappy timelines MSC3871: Gappy timelines Aug 18, 2022
@MadLittleMods MadLittleMods marked this pull request as ready for review August 18, 2022 02:39
@turt2live turt2live added proposal A matrix spec change proposal client-server Client-Server API kind:feature MSC for not-core and not-maintenance stuff needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. labels Aug 18, 2022
As suggested by @benkuly,
#3871 (comment)

The synthetic event approach is still listed as an alternative
@MadLittleMods MadLittleMods force-pushed the madlittlemods/gappy-timelines branch from d90bb0b to 5f7bb0e Compare October 7, 2022 21:46
messages anyway but they do probably see our slow `/messages` pagination.


### Expose `prev_events` to the client

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would simplify things dramatically, seems.
Same approach of gap-filling that is used for server-server could be employed for client-server.

Additionally, would make it possible for clients to issue full events, as wondered in MSC4080, since it becomes possible for clients to detect forward extremeties.

Comment on lines +41 to +42
This describes the new `gaps` response field being added to the `200 response`
of `/messages`:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably also add a gaps field to the timeline in /sync. It's important for clients to know wherever they might be missing a message.

Comment on lines +162 to +166
{
"prev_pagination_token": "t9",
"event_id": "$fred",
"next_pagination_token": "t10",
}
Copy link
Contributor Author

@MadLittleMods MadLittleMods Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this is in the context of paginating forwards)

I'm not sure whether we should consider the gap in front of the latest events to actually be a gap in the gaps list.

The problem is that the client has no way to know whether it's just a forward extremity (one of the latest events in the room) to know whether it should display the gap in the timeline. I.e. we probably don't want to display a "gap" after the latest events in the room.

We should either omit the gap for forward extremities in the room or add a field to indicate it's a forward extremity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently thinking that we should just omit the gap after the latest messages in the room. The /messages endpoint already returns start/end pagination tokens for people wanting to continue off either side. And this way clients can simply just display a gap wherever we say there is one without needing complex logic.

MadLittleMods added a commit to element-hq/synapse that referenced this pull request Aug 29, 2025
MadLittleMods added a commit to element-hq/synapse that referenced this pull request Aug 29, 2025
To try out the flow:

 - **Default to fast responses with gaps**: As a default, we can always
     respond quickly and indicate gaps ([MSC3871]
     (matrix-org/matrix-spec-proposals#3871)) for
     clients to paginate at their leisure.
 - **Fast back-pagination**: Clients back-paginate with
     `/messages?dir=b&backfill=false`, and Synapse skips backfilling
     entirely, returning only local history with gaps as necessary.
 - **Explicit gap filling**: To fill in gaps, clients use
     `/messages?dir=b&backfill=true` which works just like today to do a best
     effort backfill.

This allows the client to back-paginate the history we already have without
delay. And can fill in the gaps as they see fit.

This is basically a simplified version of [MSC4282]
(matrix-org/matrix-spec-proposals#4282).

Name | Type | Description | required
--- | --- | --- | ---
`gaps` | `[GapEntry]` | A list of gaps indicating where events are missing in the `chunk` | no
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ease of processing, we should declare that the order of the gaps is the in the same direction as the chunk of messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client-server Client-Server API kind:feature MSC for not-core and not-maintenance stuff needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. proposal A matrix spec change proposal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants