Confirming Firestore Offline Writes Before Saving LabelsConfirming Firestore Offline Writes Before Saving Labels
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
Because Firestore evaluates security rules on the server, a write queued offline can be refused after reconnection, so hold the saved label until a snapshot shows hasPendingWrites and isFromCache both false, which your listener sees only with includeMetadataChanges: true.
Post image
Sagar's avatar
Ye le Jani: This is such a crucial Firestore nuance! Most people miss the hasPendingWrites + isFromCache combo - super valuable tip for handling offline writes properly. Thanks for sharing!
Timothy's avatar
This is the kind of subtle Firestore gotcha that can haunt an app for weeks before anyone connects the dots. Holding the saved label until the snapshot confirms both flags false is a really clean rule of thumb. Have you run into this on Android and iOS equally, or does one platform's cache behavior make it trickier?
Rafee 's avatar
Good catch. Offline writes getting rejected after reconnect trips a lot of people up.
Yonatan's avatar
Holding the saved label until both hasPendingWrites and isFromCache are false is a neat rule, since a server-side security rule rejection after reconnect would otherwise leave the UI claiming a save that never happened. The includeMetadataChanges: true detail is the part I'd most likely have missed.
Dusko's avatar
Thank you! You get the point.
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started