Firebase Stack "Error: too many index entries for entity"


A few days ago several thousand errors started pouring in to Google Stackdriver about Error: too many index entries for entity from one of our Cloud Functions.

Our code hasn’t changed in a while so I believe the error is due to something in Firestore changing and causing queries or write operations to fail in this function.

The full stacktrace is below.

Note that none of the files referenced are code that we wrote, only Google’s internal stuff for functions.

Error: too many index entries for entity
    at (/srv/functions/node_modules/@grpc/grpc-js/build/src/client.js:96:45)
    at Http2CallStream.emit (events.js:194:15)
    at Http2CallStream.EventEmitter.emit (domain.js:459:23)
    at process.nextTick (/srv/functions/node_modules/@grpc/grpc-js/build/src/call-stream.js:71:22)
    at process._tickCallback (internal/process/next_tick.js:61:11)

Brief research made us believe that we had too many documents that were covered under an index. The collection being accessed by the function has around 35,000 documents right now. We deleted the one composite index we had created but the error continued to occur. The error will cause the function to crash and the HTTP request that triggered it will return an error page. This is not consistently reproducible and seems to be happening at random (around 5% of requests are failing).

I am happy to provide more information about our Firestore setup or our function source code if necessary. Any help is greatly appreciated.


According to this documentation single-field indexes “stores a sorted mapping of all the documents in a collection that contain a specific field”. If your database has 35000 documents it hit limits that you may find in the same document. This might be index entries per document or in some map or array.

I suppose that you have to setup some “Single-field index exemptions” to avoid this problem. All links needed are in the doc.

Answered By – vitooh

Answer Checked By – Mildred Charles (AngularFixing Admin)

Leave a Reply

Your email address will not be published.