8000 Uncaught Error in snapshot listener: {"code":"failed-precondition","name":"FirebaseError"} · Issue #6613 · firebase/firebase-js-sdk · GitHub
[go: up one dir, main page]

Skip to content

Uncaught Error in snapshot listener: {"code":"failed-precondition","name":"FirebaseError"} #6613

@MubashirWaheed

Description

@MubashirWaheed

[REQUIRED] Describe your environment

  • Operating System version: Ubuntu 20.04.4 LTS
  • Browser version: 104.0 (64-bit) Mozilla Firefox for Ubuntu canonical - 1.0
  • Firebase SDK version: firebase: 9.9.4
  • Firebase Product: firestore

[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

  • collection ID is posts
  • Query scope collection
  • status enabled

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);
      });
}, [])

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0