Skip to content

Firestore error

Firestore: “Transaction too big” (over the 10 MiB request limit)

“Transaction too big” is the Firestore error for a batch or transaction larger than the 10 MiB request size limit. The size includes the documents and their index entries, so a few hundred large documents can pass it. Split the writes into smaller batches.

Rather hand it over? App Fix Ticket: One reproducible bug in an existing mobile or web app, diagnosed and fixed.The Fix is $1,200 in total. The $450 Diagnosis is optional and credited toward it.

Full refund if Simon can’t take it on once he sees your project, or if you cancel before work starts. Refund terms.

Short answer

Commit in chunks, for example 100 to 200 documents per batch, and lower that if the documents are large. For big imports and migrations in the Admin SDK, use BulkWriter, which sends many writes in parallel without one giant request. Large fields you never query can also be left out of indexing to shrink each write.

Rather not fix it yourself? App Fix Ticket fixes one reproducible bug at a fixed price, with an optional Diagnosis that is credited toward the fix.

Why the write is too big, and the fix

  1. 01

    The batch is over 10 MiB

    “The transaction exceeded the maximum request size of 10 MiB.” Firebase, Transactions and batched writes

    One commit carries every write in the batch or transaction. Many documents, or a few large ones, push it over the limit.

  2. 02

    Index entries count too

    “Transaction size depends on the sizes of documents and index entries modified by the transaction.” Firebase, Transactions and batched writes

    Every indexed field adds index entries to the write. Arrays and maps with many values add many entries. Exempt large fields you never query from indexing.

  3. 03

    Split the writes into chunks

    Commit a batch, start a new one, and repeat. Batches commit one at a time, so write the job to be safe to run again if it stops halfway. This works for batched writes. A transaction can’t be split this way, so make it touch fewer documents.

    // Web SDK
    const CHUNK = 200;
    for (let i = 0; i < items.length; i += CHUNK) {
      const batch = writeBatch(db);
      for (const item of items.slice(i, i + CHUNK)) {
        batch.set(doc(db, 'products', item.id), item);
      }
      await batch.commit();
    }
  4. 04

    Use BulkWriter on the server

    “A Firestore BulkWriter that can be used to perform a large number of writes in parallel.” Google Cloud Node.js client, BulkWriter

    For imports, backfills and deletes in the Admin SDK, BulkWriter handles the batching and retries for you.

    import { getFirestore } from 'firebase-admin/firestore';
    
    const db = getFirestore();
    const writer = db.bulkWriter();
    writer.onWriteError((err) => err.failedAttempts < 3); // retry up to 3 times
    for (const item of items) {
      writer.set(db.collection('products').doc(item.id), item).catch((err) => console.error(item.id, err));
    }
    await writer.close();
  5. 05

    The 500-write rule is out of date

    “Maximum API request size 10 MiB” Firebase, Quotas and limits

    Older answers say a batch can hold 500 writes. Firebase’s current limits page lists no such count, only a request size, so a batch of small documents can hold more and a batch of large ones less.

Checked against the vendor’s docs on : Firebase docs: Transactions and batched writes; Firebase docs: Quotas and limits; Google Cloud: Firestore Node.js BulkWriter.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
A buyer in the United States, July 2022. Shopify on Fiverr
Read 126 of the 127 Fiverr reviews

Related: Firestore ALREADY_EXISTS · Firestore quota exceeded · Firestore deadline exceeded · Firestore invalid document reference · Firestore document too large

Questions

More on this error

Does splitting break atomic writes?

Yes. Each batch is all or nothing, but separate batches aren’t. If the whole set must succeed together, shrink the documents or rethink the write, not just the chunk size.

Is there a limit per document too?

Yes. A single document can be at most 1 MiB, so a too-big write can also mean one document is too large.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it. If you already know the cause, you can pay for the fix directly; if not, start with a written diagnosis, which is credited toward the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

A different error?

Ask Simon for a price range

Send the error and what you were doing. Simon replies by email, usually within one business day, with a price range.