I'm building a small chat app with expo, connected to Firestore. Here is the code to fetch the chat data:
useEffect(() => {
console.log("Loading snapShots on firebase");
const unsubscribe = db.collection('chats').onSnapshot(snapshot => (
setChats(snapshot.docs.map(doc => ({
id: doc.id,
data: doc.data()
})))
))
setTimeout(()=>{
unsubscribe();
}, 1000);
}, [])
This code is normally if I followed correctly documentation, supposed to close the snapShot listener after one second. If it does, I still get a [FirebaseError: Quota exceeded.] message and my app is very small, the data too.
I'm building a small chat app with expo, connected to Firestore. Here is the code to fetch the chat data:
useEffect(() => {
console.log("Loading snapShots on firebase");
const unsubscribe = db.collection('chats').onSnapshot(snapshot => (
setChats(snapshot.docs.map(doc => ({
id: doc.id,
data: doc.data()
})))
))
setTimeout(()=>{
unsubscribe();
}, 1000);
}, [])
This code is normally if I followed correctly documentation, supposed to close the snapShot listener after one second. If it does, I still get a [FirebaseError: Quota exceeded.] message and my app is very small, the data too.
Share Improve this question edited Sep 21, 2021 at 10:49 Alex Mamo 139k18 gold badges169 silver badges201 bronze badges asked Sep 21, 2021 at 10:39 Tercé NicolasTercé Nicolas 291 silver badge9 bronze badges 2-
Are you trying to fetch the data once and then close the listener? Why not use
get()
instead? Also if you have accidentally exceeded free quota then you would have to wait till it resets or upgrade to blaze. – Dharmaraj Commented Sep 21, 2021 at 10:42 - Thx : I will use get() now. I don't clearly understand the purpose of snashots: I see my reads explode really fast without any change on the database. Doesn't seems that it works exactly as expected ? – Tercé Nicolas Commented Sep 21, 2021 at 12:38
1 Answer
Reset to default 5Firebase quotas are reset daily at midnight (Pacific time). According to your timezone, it may differ. If you're located in Europe, it actually may be in the middle of the day. So if you reach the daily limitation, there is nothing you can do, but wait until the "next" day. Or you can update to the Spark Plan.
But remember, once you got the quota exceeded message your project will not be accessible until the quotas are reset.
As also @Dharmaraj mentioned in his ment, you might also consider using a get()
call, and not listen for real-time changes. In this way, you attach a listener that is discounted automatically once you got the data.
Please also remember to not keeping your Firebase console open, as it is considered another Firestore client that reads data. So you'll be also billed for the reads that are ing from the console.