Skip to content Skip to sidebar Skip to footer

Firebase Handle Sudden Loss In Connection

I want to know how I can control my firebase write requests when internet connection is lost suddenly. To explain my problem I will give this example: Example lets say I am doing 3

Solution 1:

In the absence of transactions, you'll need to do a few things to ensure your apps work in unreliable conditions.

  1. Write data in the order that makes it easiest to prevent or detect failures. You're writing the files first and only then update the database. Since it's likely that you trigger your other processes on the database record, they won't get triggered until step 3 completes. So you're already doing this.

  2. Write your reading code to be robust against possible incomplete data. For example: don't assume that the files are correct, or even present, even when the URL has made it into the database. And when you're reading multiple nodes from the database in separate read actions, read them in the order that makes it easiest to detect incomplete or corrupt data and skip the item in such cases.

  3. Run regular batch processes to clean up orphaned data. I'll admit that quite often this is not worth the cost, but it is a matter of good hygiene to keep the data as correct as possible.


Post a Comment for "Firebase Handle Sudden Loss In Connection"