question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firestore query failed with code=RESOURCE_EXHAUSTED, description=Quota exceeded.

See original GitHub issue

Describe your environment

  • Android Studio version: Arctic Fox 2020.3.1 Patch 3
  • Firebase Component: Firestore
  • Component version:
implementation platform('com.google.firebase:firebase-bom:28.4.1')
implementation 'com.google.firebase:firebase-firestore-ktx'

[REQUIRED] Step 3: Describe the problem

My app queries from Firestore, and when the result contains more than 2000 items, the query always fails with error WatchStream]: (c98c54b) Stream closed with status: Status{code=RESOURCE_EXHAUSTED, description=Quota exceeded., cause=null}. The detail error stacktrace can be downloaded here.

Note:

  • This problem only happens on Android SDK. I am able to query on iOS and Web without a problem.
  • This problem happens when each row contains quite significant amount of data. In my test, the final result contains around 5000 items, total size is about 120MB
  • I am on Blaze plan
  • I have waited for more than 30 minutes before executing a new query

Steps to reproduce:

Simply execute a query. The query will fail for user with a lot of data.

Relevant Code:

fun getAll() {
    val ref = FirebaseFirestore.getInstance()
        .collection("users")
        .document(userId)
        .collection("notes")
        .limit(2500)

    // This query always failed with the limit >= 2500
    ref.get(Source.SERVER)
        .addOnSuccessListener { results ->
            Log.d("Test","results size" + results.size())
        }.addOnFailureListener {
            it.printStackTrace()
            Log.d("Test", "exception ${it.localizedMessage}")
        }
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:27 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
thebrianchencommented, Nov 8, 2021

@thomasdao Yes, after looking at Francisco’s report + the absence of backend logs, it’s clear that the error is thrown by SQLite after the cache is full. To workaround this, you can either clear the cache directory with Android utility methods, or increase the size of the cache via Firestore settings.

Internally, we’ll look at improving documentation around this error case and improving the error messages. I’m going to close the issue, but feel free to ask any other questions you may have!

1reaction
bacarPereiracommented, Dec 1, 2021

@bacarPereira that’s strange, I thought 20,000 writes per day is only the free quota and not for the Blaze Plan?

That’s right. I meant spark plan. I will edit. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firestore quota exceeded for a flutter app - firebase
According to the error message: [code=resource-exhausted] can be due to over passing the cache of the device/emulator. Using Firestore settings, ...
Read more >
FirebaseFirestoreException.Code - Google
Code.RESOURCE_EXHAUSTED. Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.
Read more >
[Solved]-(333c7ef) Stream closed with status: Status{code ...
... with status: Status{code=RESOURCE_EXHAUSTED, description=Quota exceeded., ... is that the error you are getting is indeed the quotas exausted error, ...
Read more >
Troubleshooting | Firestore - Google Cloud
Latency; Error Codes ... Sustained traffic exceeding the 500-50-5 rule. read, write ... Listening to large documents or to a query with many...
Read more >
Firestore: How to stay within the limits of Firebase's new ...
Firestore's query language isn't as richly expressive as SQL is, but there are still a number of ways to restrict your queries so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found