Immutable solution version
randomly freezes for 45 seconds when getDocs after update transaction
Complete solution
Shows how to fix randomly freezes for 45 seconds when getDocs after update transaction. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
- set security rules as below: ``` rules_version =... 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.
Steps
- - Update data.
- GetDocs before updated data is fully reflected onSnapshot.
- Random freeze.
- persistentLocalCache and security rules trigger this defect with high probability.
- create new firebase project, and setup firestore.
- set security rules as below:
`
rules_version =...
- 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.
When to use
You are seeing this: Issue firebase/firebase-js-sdk#8474 (closed, 18 comments): ### Operating System macOS Sonoma 14.4 Use this skill when you run into "randomly freezes for 45 seconds when getDocs after update transaction".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: Chrome 127.0.6533.100, 10.13.1. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
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
- create new firebase project, and setup firestore.
- 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 2 · 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>