FirebaseExtended / FirebaseExtended/reactfire

Infinite request loop in useFirestoreCollection

Aperta
#374 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
v5
Lingua principale
TypeScript
Stelle
3.6k
Fork
403
Merge medio
14h 53m
PR unite (30g)
5

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
firebase, react, typescript
Ambito
databases, frontend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.