Open
Description
I have node js server with express framework with latest version when My server try to running this code parallel this gives me error like this
node_modules/geofire/dist/geofire/index.cjs.js:8458
if (other === this) {
^
RangeError: Maximum call stack size exceeded
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8458:9)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
at ChildrenNode.equals (node_modules/geofire/dist/geofire/index.cjs.js:8466:37)
Here is the my code example
function getNearBy(
center,
maxRadius,
stepRadius = 0.5,
startRadius = 0
) {
var tableRef = firebaseTable.ref("table1");
var findRef = firebaseTable.ref("table2");
return new Promise((resolve, reject) => {
try {
const queryResults = [],
geoQuery = findRef.query({
center,
radius: Math.min(maxRadius, startRadius || stepRadius)
});
geoQuery.on("key_entered", (key, location, distance) => {
var ref = tableRef.child(key);
ref.once("value").then(function (snapshot) {
if (snapshot.exists()) {
const val = snapshot.val();
queryResults.push(val)
}
});
});
geoQuery.on("ready", () => {
if (queryResults.length > 6) {
geoQuery.cancel(); // unsubscribe all event listeners and destroy query
resolve(queryResults);
return;
}
if (geoQuery.radius() >= maxRadius) {
geoQuery.cancel(); // unsubscribe all event listeners and destroy query
resolve(queryResults);
return;
}
geoQuery.updateCriteria({
radius: Math.min(maxRadius, geoQuery.radius() + stepRadius)
});
});
} catch (error) {
console.log("error", error);
}
});
}
const getNearByIDs = ({ pick_up_latitude, pick_up_longitude, radius }) => {
return new Promise((resolve, reject) => {
async function main() {
try {
const pick_up_geopoint = [
parseFloat(pick_up_latitude),
parseFloat(pick_up_longitude)
];
let id = await getNearBy(
pick_up_geopoint,
radius
);
resolve(id);
return;
} catch (error) {
console.log("error", error);
reject(error);
return;
}
}
main();
});
};
const notify = () => {
return new Promise((resolve, reject) => {
async function main() {
try {
const totalMS = 1000;
let removeDriver = "";
for (let index = 0; index < 5; index++) {
setTimeout(myFunction, i * totalMS);
async function myFunction() {
try {
let ids = await getNearByIDs({
pick_up_latitude: xx,
pick_up_longitude: xx,
radius: xx
});
} catch (error) {
console.log("error", error);
return;
}
}
}
return;
} catch (error) {
console.log("error", error);
reject(error);
return;
}
}
main();
});
};
When I try to call notify function parallel more than 2-3 times it is breaking down entire server.
Please help me with this issue
Metadata
Metadata
Assignees
Labels
No labels