Expo + firebase@9.0.1/9.0.0: @firebase/firestore:, Firestore (9.0.0): 无法到达 Cloud Firestore 后端 [英] Expo + firebase@9.0.1/9.0.0: @firebase/firestore:, Firestore (9.0.0): Could not reach Cloud Firestore backend

查看:21
本文介绍了Expo + firebase@9.0.1/9.0.0: @firebase/firestore:, Firestore (9.0.0): 无法到达 Cloud Firestore 后端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将我的 Expo 移动应用程序从 firebase@9.0.0-beta.7 更新为 firebase@9.0.1 并遇到以下错误:@firebase/firestore: Firestore (9.0.0): Could not reachCloud Firestore 后端.后端没有在 10 秒内响应.

I just updated my Expo mobile application from firebase@9.0.0-beta.7 to firebase@9.0.1 and came across following error: @firebase/firestore: Firestore (9.0.0): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.

我正在使用 android studio 模拟器在 Expo Go 中运行移动应用程序.在应用程序中,身份验证工作正常,因为我可以登录和注销用户,但是当我尝试使用 Firestore 执行某些操作时,出现以下错误:Failed to get document because the client is offline.
例如,这发生在基本的 getDoc() 函数中

I'm running mobile app in Expo Go with android studio emulator. In application Auth works fine as I can log user in and out but when I try to do something with Firestore I get following error: Failed to get document because the client is offline.
This happens for example in basic getDoc() function

const dbRef = doc(db, 'exampleColletion', 'id');
    await getDoc(dbRef).then(document => {
      const information = document.data();
      if (information !== undefined) {
        eventsRetreived(information);
      }
    }).catch((err) => {
      eventsRetreived(err);
      console.log(err.message)
    })

我已经使用 firebase@9.0.1firebase@9.0.0 进行了一些测试,但在两者中我都面临同样的问题,但在 firebase@9.0.0-beta.7 一切正常(我没有更改任何代码,只更改了 firebase 的版本).

I have made some test by using either firebase@9.0.1 or firebase@9.0.0 but in both I face the same problem but in firebase@9.0.0-beta.7 everything is working fine (and I'm not changing any code but changing only the version of firebase).

如果需要更多代码或信息,请告诉我需要添加什么,我会根据需要编辑这篇文章.

If more code or information is needed plz tell what I need to add and I will edit this post as needed.

编辑
发现了相关的 github 问题,但即使已关闭,我在测试 firebase@9.0.2 后仍然面临这个问题
https://github.com/firebase/firebase-js-sdk/issues/5402

EDIT2
似乎问题出现在 Expo v. 42 中.目前 Expo 默认支持兼容版本的 Firebase,因此目前的解决方案是使用 firebase@9.0.0-beta.7 或兼容版本由 Expo 支持并通过 expo install firebase

EDIT2
Seems like issue is appearing in Expo v. 42. At the moment Expo support by default compat version of Firebase so the solution at the moment is to use firebase@9.0.0-beta.7 or compat version that is supported by Expo and is installed through expo install firebase

推荐答案

我可以使用这个设置让它工作:

I can get it to work by using this setting:

initializeFirestore(firebaseInstance.current, {
  // @ts-ignore
  useFetchStreams: false,
  cacheSizeBytes: 100000000,
})

似乎 iOS 不想很好地使用 Fetch API,使用 useFetchStreams 回退到使用 XMLHttpRequest 代替,目前这似乎对我有用.我在 firebase 9.0.2.

Seems iOS does not want to play nice with the Fetch API, using useFetchStreams falls back to using XMLHttpRequest instead, which seems to do the trick for me at the moment. I'm on firebase 9.0.2.

这篇关于Expo + firebase@9.0.1/9.0.0: @firebase/firestore:, Firestore (9.0.0): 无法到达 Cloud Firestore 后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆