Google firestore 失去连接且无法重新连接

问题描述 投票:0回答:1

我不断在控制台和 logrocket 中收到这些错误,其中请求状态为失败 https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?gsessionid={sessionId} &VER=8&database=projects%2F{project-id}%2Fdatabases%2F(默认)&RID=rpc&SID=K27t2X6s-fMH7p5g_cW8VQ&AID=126&CI=0&TYPE=xmlhttp&zx=zdzob1237mbu&t=2

我的 logrocket 中有数千个这样的错误,我需要通过重新连接来处理这些故障吗?或者是否有我可以添加到 javascript sdk 以自动重新连接的配置?

enter image description here

这是失败的代码。


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();
  }, []);
firebase google-cloud-firestore
1个回答
0
投票

无法检测连接错误。 SDK 会自动为您重试,重新连接后您的查询最终会成功。

另请参阅:

© www.soinside.com 2019 - 2024. All rights reserved.