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

Handling record modified on server after lastPulledAt #2

Open
pokey opened this issue Jul 8, 2020 · 0 comments
Open

Handling record modified on server after lastPulledAt #2

pokey opened this issue Jul 8, 2020 · 0 comments

Comments

@pokey
Copy link

pokey commented Jul 8, 2020

I believe this code doesn't conform to one of the requirements for implementing the push endpoint. In the spec, it says:

  1. If the changes object contains a record that has been modified on the server after lastPulledAt, you MUST abort push and return an error code
  • This scenario means that there's a conflict, and record was updated remotely between user's pull and push calls. Returning an error forces frontend to call pull endpoint again to resolve the conflict

I believe that the proper way to handle this would be to use Firestore transactions that check that updatedAt and deletedAt (and createdAt?) are less than lastPulledAt. Could either be one transaction per operation, or one big transaction, keeping in mind that it would be possible in theory to hit the 500 write limit for transactions. One advantage of using a single transaction, though, is that it would mean the code would also satisfy rule 7:

  1. The push endpoint MUST be fully transactional. If there is an error, all local changes MUST be reverted, and en error code MUST be returned.

But cool library; thanks for making it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant