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
我刚刚将我的 Expo 移动应用程序从 firebase@9.0.0-beta.7 更新到 firebase@9.0.1 并遇到以下错误:@firebase/firestore: Firestore (9.0.0): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
.
我是 运行 Expo Go 中的移动应用程序,使用 android studio 模拟器。
在应用程序中,Auth 工作正常,因为我可以让用户登录和注销,但是当我尝试使用 Firestore 执行某些操作时,出现以下错误:Failed to get document because the client is offline.
例如,在基本的 getDoc() 函数中会发生这种情况
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.1
或 firebase@9.0.0
进行了一些测试,但在两者中我都遇到了同样的问题,但在 firebase@9.0.0-beta.7
中一切正常(而且我没有改变任何代码,但仅更改 firebase 的版本)。
如果需要更多代码或信息,请告诉我需要添加什么,我将根据需要编辑此 post。
编辑
找到了相关的 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 支持并通过 [= 安装的兼容版本18=]
我可以使用此设置让它工作:
initializeFirestore(firebaseInstance.current, {
// @ts-ignore
useFetchStreams: false,
cacheSizeBytes: 100000000,
})
似乎 iOS 不想很好地使用 Fetch API,使用 useFetchStreams
回退到使用 XMLHttpRequest
,这似乎可以解决此刻的我。我在使用 Firebase 9.0.2
.
我刚刚将我的 Expo 移动应用程序从 firebase@9.0.0-beta.7 更新到 firebase@9.0.1 并遇到以下错误:@firebase/firestore: Firestore (9.0.0): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
.
我是 运行 Expo Go 中的移动应用程序,使用 android studio 模拟器。
在应用程序中,Auth 工作正常,因为我可以让用户登录和注销,但是当我尝试使用 Firestore 执行某些操作时,出现以下错误:Failed to get document because the client is offline.
例如,在基本的 getDoc() 函数中会发生这种情况
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.1
或 firebase@9.0.0
进行了一些测试,但在两者中我都遇到了同样的问题,但在 firebase@9.0.0-beta.7
中一切正常(而且我没有改变任何代码,但仅更改 firebase 的版本)。
如果需要更多代码或信息,请告诉我需要添加什么,我将根据需要编辑此 post。
编辑
找到了相关的 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 支持并通过 [= 安装的兼容版本18=]
我可以使用此设置让它工作:
initializeFirestore(firebaseInstance.current, {
// @ts-ignore
useFetchStreams: false,
cacheSizeBytes: 100000000,
})
似乎 iOS 不想很好地使用 Fetch API,使用 useFetchStreams
回退到使用 XMLHttpRequest
,这似乎可以解决此刻的我。我在使用 Firebase 9.0.2
.