firebase / firebase/firebase-js-sdk
Avoid setTimeout in Firestore
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
I've created this issue based on an internal bit of feedback:
> Firestore reads are much slower when the tab is not focused.
>
> When the browser tab is not focused, Firestore reads always take over a second. This is likely because a setTimeout is being used in the code and when a tab is unfocused setTimeouts always take 1 second or more to complete, even if they are requested to be milliseconds long.
>
> You should consider using Promise.resolve().then(theDelayedFunction) instead of setTimeout(theDelayedFunction) to allow queuing all operations in a single tick. This will accomplish the same thing without the throttle the browser adds to setTimeouts.
Contributor guide
Assessment
This issue has not been assessed yet.