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

WriteBatch.commit cannot be used in a sync way #2822

SamyPesse opened this issue Mar 29, 2020 · 1 comment · Fixed by #2823

WriteBatch.commit cannot be used in a sync way #2822

SamyPesse opened this issue Mar 29, 2020 · 1 comment · Fixed by #2823


Copy link

@SamyPesse SamyPesse commented Mar 29, 2020

When using .set, .update on DocumentReference, we can directly do a .get after without risking invalid data in the "local database".

But since WriteBatch.commit is written as an AsyncFunction, it defers the commit to the "local database" to the next event loop.

I'm not sure wherever the original use case is supported, but it'd be great to have consistency between those methods. I've spent some time debugging a timing issue in my React application with a code like (where the navigate cause a read-sync in and use a suspense firestore cache):

const batch = firestore().batch();
const post = ...
batch.commit();  // The changes will no be applied in the local firestore before after the call to navigate.


While it'll work with:

const post ...

Copy link

@google-oss-bot google-oss-bot commented Mar 29, 2020

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging a pull request may close this issue.

3 participants