firebase / firebase/geofire-js

Internal State error, trying to remove location that is still in query

Open
#133 8 comments 3 reactions 0 assignees View on GitHub
type: bug
Dominant language
TypeScript
Stars
1.4k
Forks
339
PR merge metrics
No merged PRs in 30d

Description

Took me a while to reproduce this on the example, but here's a screenshot:

![screenshot 2017-01-30 21 40 26](https://cloud.githubusercontent.com/assets/287330/22420165/075c9750-e735-11e6-80c1-17c66babfc7b.png)

To reproduce, visit https://geofire.firebaseapp.com/queryBuilder/index.html and create a fish with latlng `34.0489281,-111.09373110000001` then create a query with radius 10000 and latlng `43.92630646953202,127.05690366562499` then update the query with latlng `43.16183777054158,-116.57590883437501` and then revert it back to latlng `43.92630646953202,127.05690366562499` and update it few times and it throws the error:

"Internal State error, trying to remove location that is still in query"

Now my wild guess as to why this happens is that the earth has a diameter of 12742km and so the biggest search radius should be half that. I tried drawing a circle on Google Maps and with the same radius as the query and depending where the center is and how far you're zoomed out you get a sine wave as opposed to a circle, and so I can only guess that when the search radius is too big you end up with an "overlap" or maybe a situation where a key is both in and out of the search circle at the same time. Again, this is only a guess.

I'd love a way to overcome this problem, and my current "solution" is based on my wild guess where I limit the size of the query radius to 6371km (half the diameter of the world to avoid circle overlap).

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in the GeoFire queryBuilder at https://geofire.firebaseapp.com/queryBuilder/index.html using the coordinates, radius, and repeated query updates from the issue. Trace the query-update path around the “trying to remove location that is still in query” error and determine why the same location is treated as both inside and outside the query; done means the sequence completes without the internal-state error.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, typescript
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.