Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Permission error when accessing a cached firestore collection after logout/login

Aperta
#485 4 commenti 10 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Riproduci la sequenza di sign-out/sign-in con useFirestoreCollectionData e la stessa collection, quindi esamina come la cache globale delle collection gestisce le modifiche all’autenticazione. Confronta la lettura dalla cache con il workaround che consiste nel cambiare idField dopo il login. Il lavoro è completato quando la stessa collection può essere letta dopo la riautenticazione senza un errore di autorizzazione, idealmente con un test di regressione o una riproduzione documentata.

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

Descrizione

v5
Version info

React: 17.0.2

Firebase: 9.4.0

ReactFire: 4.2.0

Other (e.g. Node, browser, operating system) (if applicable): Chrome, Windows 10

Test case

Test cases seem challenging to produce since a firebase instance is involved.

Steps to reproduce
  1. Sign In (I used GoogleAuthProvider), or be already signed-in.
  2. Read from a collection.
  3. Sign Out
  4. Sign In
  5. Read from the same collection.
Expected behavior

The same data is read.

Actual behavior

Uncaught FirebaseError: Missing or insufficient permissions. is thrown.

This seems to be caused by the global cache of collections. The problem can be mitigated by:

  • Refreshing the page after sign out
  • Changing the idField passed to useFirestoreCollectionData. Any easy way to test this is to use id-${auth.stsTokenManager.expirationTime} as your idField, since expirationTime changes on every Sign Out/In cycle.

Note that waiting more than 30 seconds does not fix the problem. So, the cache resetting of the collection is insufficient to resolve the issue. I suspect that the collection is associated with the stale auth token which has been disabled due to logout.

A possible resolution might be to purge the cache on sign out.

Lingua principale
TypeScript
Stelle
3.6k
Fork
403
Merge medio
5g 1h
PR unite (30g)
10

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FirebaseExtended/reactfire

Tutte le issue di FirebaseExtended/reactfire

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.