0

I'm trying to fetch documents thats belongs to a certain user and just documents which contains status from 1,2,4,5,6 , but instead of getting the documents I'm getting a weird error, this is the code which fetchs for orders with just that status into Firestore

suspend fun getIncompletedOrders(): Resource<List<Order>> {
        val reminderList = mutableListOf<Order>()
        val query = FirebaseFirestore.getInstance().collection("orders").whereEqualTo("uid",FirebaseAuth.getInstance().currentUser).whereIn("status",
            listOf(1,2,4,5,6)).get().await()
        for(documents in query.documents){
            reminderList.add(documents.toObject(Order::class.java)!!)
        }
        return Resource.Success(reminderList)
    }

This code is throwing the following error

java.lang.StackOverFlowError: stack size 1041KB at com.gogle.firebase.firestore.util.CustomClassMapper$ErrorPath.toString(com.google.firebase:firebase-firestore@@21.4.3:1155)

Firebase Structure

   |_ orders
            |_ docID
                   |_ status: 2
                   |_ uid: userID

Order

data class Order(
    val cart: MutableList<Cart> = mutableListOf(),
    val shopName:String = "",
    val deliveryPrice: Int = 0,
    val wantDelivery: Boolean = false,
    val address:String = "",
    val paymentMethod: Int = 0,
    val total: Int = 0,
    val uid: String = "",
    val status: Int = 0,
)

I dont really know where the problem is

SNM
  • 5,625
  • 9
  • 28
  • 77

1 Answers1

0

Seems as the document you are trying to pass to your collection is too big, according with this :

"The Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. Consequently this exception can be thrown when there are many transactions in progress even when most of the individual transactions are of moderate size."

On this thread was answered a similar question, maybe you want to take a look on it.

Could you share further details about the document you are handling and the complete trace error?

Harif Velarde
  • 733
  • 5
  • 10
  • but the document just has 2 fields, thats weird and there is only one document, also it should handle a rejection in the coroutine instead of doing this crash – SNM Jul 11 '20 at 01:14
  • Just to confirm could you share the complete structure of Order? Just as a kind reminder objects that are coming from the database, it requires that any objects in use, to have a public no-argument constructor, you can check that on this document https://firebase.google.com/docs/database/android/read-and-write#basic_write – Harif Velarde Jul 16 '20 at 18:55