question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Firestore: Operation was rejected because the system is not in a state required for the operation`s execution.

See original GitHub issue

According to the Firebase Cloud Firestore documentation for orderBy this should work:

var facultyQuery = facultyRef.where("Middle School", "==", true).orderBy('bb_last_name', 'desc');

I also tried this to make sure it wasn’t the Map data causing issues:

var facultyQuery = facultyRef.where("department", "==", "Core Teacher").orderBy('bb_last_name', 'desc');

However it produces the error:

Error: Firestore: Operation was rejected because the system is not in a state required for the operations execution. (firestore/failed-precondition).`

Both of these simpler cases work just fine:

var facultyQuery = facultyRef.orderBy('bb_last_name', 'asc');
var facultyQuery = facultyRef.where("department", "==", "Core Teacher");

But when I combine the where and the orderBy, something I have done before with other Firestore collections, it fails. The documentation also states that “…queries that only use equality clauses don’t need additional indexes” so I did not think I needed one.

spkcb

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
schmidt-sebastiancommented, Jan 10, 2018

@agersoncgps In the error message that you are seeing, there should be a http link that allows you to add an index. Any query that you issue that uses more than one field needs a composite index, and you need to define these indices beforehand. Please take a look here: https://firebase.google.com/docs/firestore/query-data/indexing

Queries that only involve one field will work with a the built-in indices.

1reaction
jeremyfranciscommented, Dec 15, 2018

The link appears if you run adb logcat if you are running on Android, but not in the Chrome error console, which is where I think it should be. Where would an iOS developer see it?

I just did console.log(JSON.stringify(error)) and clicked the link in Chrome. Added for me right away.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Firestore: Operation was rejected because the system is ...
Error: Firestore: Operation was rejected because the system is not in a state required for the operation`s execution. #453.
Read more >
Still get error 'Operation was rejected because the system is ...
I get this error 'Operation was rejected because the system is not in a state required for the operation's execution' then I created...
Read more >
Manage indexes in Cloud Firestore - Firebase - Google
An indexing operation can fail if Cloud Firestore encounters a problem with the data it's indexing. Most commonly, this means you hit an...
Read more >
“Firestore: Operation was rejected because the system is not ...
“Firestore: Operation was rejected because the system is not in a state required for the operation`s execution.
Read more >
Functions - Firebase Modular JavaScript SDK Documentation
FunctionsError, An error returned by the Firebase Functions client SDK. ... Operation was rejected because the system is not in a state required...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found