Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/messages does not provide a way of saying that you cannot paginate further #2251

Closed
ara4n opened this issue Aug 28, 2019 · 12 comments
Closed
Labels
client-server Client-Server API improvement A suggestion for a relatively simple improvement to the protocol

Comments

@ara4n
Copy link
Member

ara4n commented Aug 28, 2019

We need to define the error code or mechanism to inform the user that they can't back-paginate further via /messages because the server has run out of DAG.

@ara4n
Copy link
Member Author

ara4n commented Aug 28, 2019

@turt2live turt2live added client-server Client-Server API spec-bug Something which is in the spec, but is wrong labels Aug 28, 2019
@KitsuneRal
Copy link
Member

KitsuneRal commented Aug 29, 2019

Do we really need to invent anything here if /messages returns state changes and m.room.create is (supposed to be) still the very first event no matter how you purge messages?

@richvdh
Copy link
Member

richvdh commented Aug 29, 2019

it's not really a spec-bug imho: it's something we need to agree on and spec.

@KitsuneRal: that is one solution, but there are others which would make just as much (or more) sense. It's worth remembering that /messages lets you go both ways so we could do with a solution that works in the other direction too.

@turt2live
Copy link
Member

err, yes - it should be an improvement not a bug. I wonder which issue I was trying to label as a bug....

@turt2live turt2live added improvement A suggestion for a relatively simple improvement to the protocol and removed spec-bug Something which is in the spec, but is wrong labels Aug 29, 2019
@ara4n
Copy link
Member Author

ara4n commented Sep 3, 2019

According to #1763 (comment) @turt2live thinks that the absence of a next_batch token should be specced to mean "you cannot paginate further", which feels very sane to me. Shall we do that (if it's not already?)

@richvdh
Copy link
Member

richvdh commented Sep 3, 2019

/messages doesn't have a next_batch. I think you mean end, in which case +1

@joepie91
Copy link

joepie91 commented Jul 21, 2020

Do we really need to invent anything here if /messages returns state changes and m.room.create is (supposed to be) still the very first event no matter how you purge messages?

Yes. The same problem occurs when you specify a to parameter (to fetch missing backlog in a limited /sync response for example), in which case you don't know what the final event is going to be. The only solutions right now are:

  1. Checking whether the amount of results is less than the limit (fragile, will break in 1/Nth of cases)
  2. Continuing to paginate until an empty chunk is produced (seemingly reliable, but requires a pointless extra request)

According to #1763 (comment) @turt2live thinks that the absence of a next_batch token should be specced to mean "you cannot paginate further", which feels very sane to me. Shall we do that (if it's not already?)

That sounds entirely reasonable to me, and would be in line with how pagination is designed in most HTTP APIs.

@richvdh
Copy link
Member

richvdh commented Mar 17, 2021

Continuing to paginate until an empty chunk is produced (seemingly reliable, but requires a pointless extra request)

not entirely reliable, sadly. Synapse will sometimes return empty chunks if there is a section of timeline you're not allowed to see (eg because you weren't in the room).

@richvdh
Copy link
Member

richvdh commented Apr 30, 2021

For the record, it looks like matrix-js-sdk currently decides that it's at the end of the timeline if start == end in the response.

@richvdh
Copy link
Member

richvdh commented Sep 20, 2021

This got fixed by #3353.

@bakkot
Copy link

bakkot commented Oct 2, 2021

To be clear, accepted solution is "you can detected the end of the line by the absence of an end token in the response", right?

I note that this is not the behavior on matrix.org currently, which will always return an end token. That's fine, but it's a bit annoying that someone just reading the spec [e.g. me] is going to end up in an infinite loop when trying to write a client against the matrix.org homeserver.

@richvdh
Copy link
Member

richvdh commented Oct 4, 2021

I note that this is not the behavior on matrix.org currently, which will always return an end token.

please file an issue against https://github.com/matrix-org/synapse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client-server Client-Server API improvement A suggestion for a relatively simple improvement to the protocol
Projects
None yet
Development

No branches or pull requests

6 participants