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

Clicking on Add Mock Ratings shows 400 error responses #25

Closed
rodrigomata opened this issue Jul 11, 2018 · 3 comments
Closed

Clicking on Add Mock Ratings shows 400 error responses #25

rodrigomata opened this issue Jul 11, 2018 · 3 comments
Assignees

Comments

@rodrigomata
Copy link

rodrigomata commented Jul 11, 2018

Error:

Clicking on Add Mock Ratings shows 400 error responses
screen shot 2018-07-11 at 5 19 14 pm

Response:
{ "error": { "code": 400, "message": "the stored version (1531347069149658) does not match the required base version (1531346493121653)", "status": "FAILED_PRECONDITION" } }

Image:

screen shot 2018-07-11 at 5 17 28 pm

Steps to reproduce:

  1. Complete codelab
  2. Click on a restaurant
  3. Click on Mock Review

EDIT: It only happens when more than 1 review is mocked

@axis80
Copy link

axis80 commented Aug 13, 2018

I have a related Stack Overflow issue here: https://stackoverflow.com/questions/51814139/firestore-transaction-produces-console-error-failed-precondition-the-stored-ve . Hopefully a solution on either this issue or that question will lead to a solution on the other one.

@nicolasgarnier
Copy link
Contributor

What you are experiencing here is how Transactions work in Firestore: one of the transactions failed to write because the data has changed in the mean time, in this case Firestore re-runs the transaction again, until it succeeds. In the case of multiple Reviews being written at the same time some of them might need to be ran again after the first transaction because the data has changed. This is expected behavior and these errors should be taken more as warnings.

@Metsuryu
Copy link

@nicolasgarnier is there a way to catch the error and handle it silently, instead of always printing it to the console?
I tried using .catch on the promise, and wrapping everything into a try-catch, but it still always prints the 400 error to the console.

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

5 participants