Firebase - Values updated automatically reverted

Ah ha, here I come back again. I have been trying to deal with constant app crashes and now, to my surprise, a serious problem with Firebase.

I made a button to mass update some values on a Firebase database. I click the button and rush to Firebase screen, where I can see every data being update, one by one. Just like a dream… But it becomes a nightmare when after some time, I look again at all my data and I realize that all the update I made has been REVERTED as if I had never done anything.

Has anyone experienced this?

Well, my data base is both readable and writable…

1 Like

How did you insert the original data? Show your blocks.

If you’re inserting it on the app startup then every app startup will set original data.

1 Like

Ooops, it’s quite a big one…

The original data was updated to Firebase from a JSON list (made in Excel). The only thing I change in the list is the field BOX. To do so, I have this code below:

1 Like

Everytime I update this field, I check FIREBASE and everything is perfect. After some time I look back and this action has been reverted… Today it happened 3 times to me.

Could it be a problem with cache or some kind of memory?!
The code is really working, the problem is that it undo later. I have to other task to mass call the database.

Here you can see it working:

1 Like

Hello,

I think the problem is not in FireBase, but in the algorithm. From your blocks, I see that you are in a loop trying to work with asynchronous get and set methods using the synchronous approach and delay. Such an algorithm is an excellent source of permanent errors.

What problem do you need to solve?

Do you see the “error” block in the Get and Save methods? This block is used to track errors, but your code ignores the occurrence of errors and continues to call these methods in a loop.

Do you understand how the work of asynchronous blocks differs from synchronous?

1 Like

Yes, in fact I have to put some delay, otherwise it skips the whole task without acomplishing anything.

My code ignore errors! :rofl: I really don’t know how to use this error block. What would you advise me to treat this error? Do you have any example for me to take a look?

1 Like

Unfortunately, I do not have a ready-made example yet, but Mark showed an example of working with an asynchronous block.

I do not know your final task, but I would consider the option when we first prepare all the data to write to FireBase, and then save it with just one call to the Save method.

3 Likes

Wow, thank you so much for this link you sent me. It really clarified my mind. I had no clue of the problem and as I am not a programmer or anything related to IT, I don’t know how to debug. This is the 4th “bug”/“limitation” I come across here on Thunkable.
It would be really good if these limitations were directly updated in the manual. I was almost giving up of my project…
Thank you once again. :smiling_face_with_three_hearts:

1 Like

Thanks, @IWendling! We have some plans to make our asynchronous blocks easier to use, so that they work better within loops.