Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should adding multiple Firestore snapshot listeners simultaneously be avoided?

This has been a difficult problem to debug because I don't know for certain where the problem is and I can't reproduce it on purpose. I have an iOS app that can have up to about 15 Firestore snapshot listeners that are instantiated at app launch. Sometimes a listener will get hung up and never return and sometimes it generates a network connection error but most of the time it doesn't generate any error--it just becomes and remains unresponsive until the app is rebooted.

I figured that perhaps too many snapshot listeners were being instantiated simultaneously so I staggered their instantiation over a few seconds and it appears to have remedied the problem because I haven't had it since, but, again, reproducing this problem has proven difficult.

Therefore, should adding multiple snapshot listeners simultaneously be avoided? Is there a good reason why adding too many at the same time might cause some of them to act unexpectedly?

like image 247
liquid LFG UKRAINE Avatar asked Feb 23 '26 21:02

liquid LFG UKRAINE


1 Answers

Within the Firestore best practices documentation, you can see that it’s recommended to keep the number of snapshot listeners per client under 100, and to avoid frequently adding or removing snapshot listeners in the same connection since this can cause performance issues.

like image 63
David Avatar answered Feb 26 '26 09:02

David



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!