Uncaught Error in snapshot listener: {"code":"failed-precondition","name":"FirebaseError"} (original) (raw)

[REQUIRED] Describe your environment

[REQUIRED] Describe the problem

Steps to reproduce:

I am not getting the link to add an index for the compound queries in my console. and instead, I am getting this error in the console
[2022-09-18T05:53:50.590Z] @firebase/firestore: Firestore (9.9.4): Uncaught Error in snapshot listener: {"code":"failed-precondition","name":"FirebaseError"}
After going through stackoverfollow I manually created the composite indexes in the firebase console under the firestore> indexes.

  1. index Descending, createdBy Descending
  2. index Descending, createdBy Arrays

for both indexes

When I remove the orderBy there is no error.

Relevant Code:

following is an array with string values and the index field has number as its value
ps: I am using react.

// TODO(you): code here to reproduce the problem useEffect(()=>{ const q = query( collection(db, "posts"), orderBy("index", "desc"), where("createdBy", "in", following) ); const unsubscribe = onSnapshot(q, (querySnapshot) => { const data = []; querySnapshot.forEach((doc) => { data.push(doc.data()); }); setPosts(data); }); }, [])