Skip to content
← Back to activity

Immutable solution version

randomly freezes for 45 seconds when getDocs after update transaction

Version 1Sign in to save

Complete solution

Teaches how to randomly freezes for 45 seconds when getDocs after update transaction. Based on a real issue report and its verified fix.

The problem

Issue firebase/firebase-js-sdk#8474 (closed, 18 comments): ### Operating System

macOS Sonoma 14.4

Environment (if applicable)

Chrome 127.0.6533.100

Firebase SDK Version

10.13.1

Firebase SDK Product(s)

Firestore

Project Tooling

No-bundle (using cdn to reproduce)

Detailed Problem Description

  • Update data.
  • GetDocs before updated data is fully reflected onSnapshot.
  • Random freeze.
  • persistentLocalCache and security rules trigger this defect with high probability.

Steps and code to reproduce issue

  1. create new firebase project, and setup firestore.
  2. set security rules as below:
rules_version =...

## What to do
If Firestore randomly freezes for tens of seconds on getDocs after an update transaction (persistentLocalCache plus security rules make it very likely), the trigger is a client-side index. Workaround: delete any existing client-side indexes and make sure client-side index auto creation stays disabled. Get the index manager with getPersistentCacheIndexManager(firestore), call deleteAllPersistentCacheIndexes on it, then disablePersistentCacheIndexAutoCreation. You can still add indexes manually with setIndexConfiguration for collections that need them.

Evidence

In the GitHub issue gh:firebase/firebase-js-sdk#8474 (https://github.com/firebase/firebase-js-sdk/issues/8474), the problem reported was: Issue firebase/firebase-js-sdk#8474 (closed, 18 comments): ### Operating System

macOS Sonoma 14.4

Environment (if applicable)

Chrome 127.0.6533.100

Firebase SDK Version

10.13.1

Firebase SDK Product(s)

Firestore

Project Tooling

No-bundle (using cdn to reproduce)

Detailed Problem Description

  • Update data.
  • GetDocs before updated data is fully reflected onSnapshot.
  • Random freeze.
  • persistentLocalCache and security rules trigger this defect with high probability.

Steps and code to reproduce issue

  1. create new firebase project, and setup firestore.
  2. set security rules as below:
rules_version =... The verified resolution was: If Firestore randomly freezes for tens of seconds on getDocs after an update transaction (persistentLocalCache plus security rules make it very likely), the trigger is a client-side index. Workaround: delete any existing client-side indexes and make sure client-side index auto creation stays disabled. Get the index manager with getPersistentCacheIndexManager(firestore), call deleteAllPersistentCacheIndexes on it, then disablePersistentCacheIndexAutoCreation. You can still add indexes manually with setIndexConfiguration for collections that need them.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_LZk1VWwktusZeUlCjRfURQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">randomly freezes for 45 seconds when getDocs after update transaction <span>— Vectle</span></a>