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

Implement better data consistency for realtime subscriptions #36

Open
MJDeligan opened this issue Sep 17, 2022 · 1 comment
Open

Implement better data consistency for realtime subscriptions #36

MJDeligan opened this issue Sep 17, 2022 · 1 comment
Labels
bug Something isn't working enhancement New feature or request improvement improves existing features

Comments

@MJDeligan
Copy link
Collaborator

Currently the realtime events work as follows:

  1. When the page is loaded a realtime observer on the event is established
  2. Immediately after that, the event is fetched and awaited
  3. We check if the event has started
  4. If it has, we try to fetch the current round and set the event_started flag to true
  5. If there is a current round info (which includes information about a potential pair this round), we check if it has not ended not
  6. If it has we set up all the required flags
  7. When the event_started flag is changed to true, we establish realtime connections for user_pairs and rounds

This works, but it's not entirely consistent as it doesn't handle the realtime subscriptions interrupting and missing updates. There's also a gap between the data being fetched and the realtime subscription being established.

If a user reloads the page and fetches the data, then starts establishing the realtime subscription, but the organizer pushes a new round between the time the user fetched the data and the time the realtime subscription is established, then their fetched data won't include the new round, but the realtime subscription will have missed it as well, desyncing the user.

As detailed here we can listen to the state of the subscription and based on those we can then (re-)fetch data.

@MJDeligan MJDeligan added bug Something isn't working improvement improves existing features labels Sep 17, 2022
@MJDeligan
Copy link
Collaborator Author

So apparently this is no longer as easy with the v2-client and requires using the "raw" realtime channel subscription instead of the ones that you get from .from(<table>).on(<stuff>).subscribe(). That solution requires the usage of raw string to detect the event of the subscription and the API seems to still be quite volatile in that regard, so there is no guarantee it won't just break with an update.

For now we may have to just accept that there times where we might miss data, sadly.

@sueszli sueszli added the enhancement New feature or request label Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request improvement improves existing features
Projects
None yet
Development

No branches or pull requests

2 participants