FirebaseExtended / FirebaseExtended/reactfire

Infinite request loop in useFirestoreCollection

未关闭
#374 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
v5
主要语言
TypeScript
星标
3.6k
派生
403
平均合并
14 小时 53 分钟
30 天内合并 PR
5

描述

Hello,

the following code results in an infinite loop when user isn't authenticated aka `user.data` is `undefined`. Is this expected?

```
const user = useUser(undefined, { suspense: true });
const subscriptions = useFirestoreCollection(
firestore
.collection('customers')
.doc(user.data?.uid)
.collection('subscriptions')
```

When something random and non-existent is passed to `doc(myId)`, it throws `Missing or insufficient permissions`, when `null` is passed it throws `Function CollectionReference.doc() cannot be called with an empty path`, however when `undefined` is passed the code goes into an infinite loop and triggers hundreds of requests per second.

贡献指南

打开贡献指南

调研方向

Reproduce the issue with the shown useUser and useFirestoreCollection snippet, then trace how useFirestoreCollection handles an undefined document path. Compare its behavior with null and a nonexistent id; done means the undefined case no longer causes repeated requests and has a defined outcome.

由索引模型根据 Issue 内容生成。

评估

技术栈
firebase, react, typescript
领域
databases, frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。