I am using real time database as firebase and i used geofire javascript package to get near by data from firebase. but some time it automatically gives error like :
RangeError: Maximum call stack size exceeded
at ChildrenNode.isLeafNode (api/node_modules/firebase-admin/node_modules/@firebase/database-compat/dist/index.standalone.js:8956:50)
at ChildrenNode.equals (api/node_modules/geofire/dist/geofire/index.cjs.js:8461:24)
this is my sample query to find near by things from firebase realtime database using geofire
while (some amount) {
geoDriverId = await(new Promise((resolve, reject) => {
try {
geoDriverId = []
geoDriverIds = []
const geoQuery = config.firebase.table.query({
center: [parseFloat(pick_up_latitude), parseFloat(pick_up_longitude)],
radius: i
})
let listener = geoQuery.on("key_entered", (key, location, distance) => {
geoDriverIds.push({ key, distance });
});
geoQuery.on("ready", (key, location, distance) => {
listener.cancel();
geoQuery.cancel();
resolve(geoDriverIds);
return;
});
} catch (e) {
console.log("e", e)
}
}))
}
If the intention is to poll for the initial results of the query, consider using the following method instead (this is effectively the code you provided in the question, cleaned up and turned into a method):
Usage:
To sort the results by the distance from the center point:
If the intention is to find only the closest result, you can use the following method to progressively search for results:
Usage: