0

I am continually getting these errors in my console and in logrocket, where the status of the request is failed https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?gsessionid={sessionId}&VER=8&database=projects%2F{project-id}%2Fdatabases%2F(default)&RID=rpc&SID=K27t2X6s-fMH7p5g_cW8VQ&AID=126&CI=0&TYPE=xmlhttp&zx=zdzob1237mbu&t=2

I have thousands of these errors in logrocket, do I need to handle these failures by reconnecting? Or is there a configuration I can add to the javascript sdk to reconnect automatically?

enter image description here

This is the code that is failing.


const useProductAmmendments = (dispatch, clientId: string) => {
  useEffect(() => {
    async function fetch() {
      const modifierGroupsQuery = query(collection(getFirestore(), `${clientId}/products/modifierGroups`), where("enabled", "==", true));
      const additionGroupsQuery = query(collection(getFirestore(), `${clientId}/products/additionGroups`), where("enabled", "==", true));
      const preparationGroupsQuery = query(collection(getFirestore(), `${clientId}/products/preparationGroups`), where("enabled", "==", true));
      const upsellGroupsQuery = query(collection(getFirestore(), `${clientId}/products/upsellGroups`), where("enabled", "==", true));
      const [snap1, snap2, snap3, snap4] = await Promise.all([getDocs(modifierGroupsQuery), getDocs(additionGroupsQuery), getDocs(preparationGroupsQuery), getDocs(upsellGroupsQuery)]);
      dispatch(
        setProductAmmendments({
          modifierGroups: snap1.docs.map((d) => ({ id: d.id, ...d.data() })),
          additionGroups: snap2.docs.map((d) => ({ id: d.id, ...d.data() })),
          preparationGroups: snap3.docs.map((d) => ({ id: d.id, ...d.data() })),
          upsellGroups: snap4.docs.map((d) => ({ id: d.id, ...d.data() })),
        })
      );
    }
    fetch();
  }, []);

1 Answer 1

0

It's not possible to detect connection errors when using one of the provided SDKs for Firestore. The SDK will retry for you automatically, and your queries will eventually succeeds when it reconnects.

See also:

Not the answer you're looking for? Browse other questions tagged or ask your own question.