I have found what seems to be a weird bug in either the Firebase Javascript lib or the API itself:
When using a simple ref.limit() query for a simple nested data structure, Firebase sometimes returns wrong data under specific conditions. I have set up a simple jsfiddle to demonstrate.
How to reproduce:
(ideally, create your own firebase and replace the URL to avoid any problems from other people testing it out)
2. Insert two new entries into the data structure
3. Delete the last entry
4. Reload one of the pages
Query:
Returned data after page reload:
{
parent: {
firstChildName: true,
secondChildName: {firstChildName: true} <-- weird! also, this was deleted
}
}
Expected data:
{
parent: {
firstChildName: true
}
}
The wrong data is only returned for the exact same query. Changing it, e.g. by changing or removing the limit, or looking at Forge shows the correct data.
I've also seen this after inserting data without subsequently deleting, but cannot reliably reproduce.
I'm grateful for any hints or workarounds.