Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum call stack size exceeded error #267

Open
vasu-rangpariya-xl opened this issue May 9, 2023 · 1 comment
Open

Maximum call stack size exceeded error #267

vasu-rangpariya-xl opened this issue May 9, 2023 · 1 comment

Comments

@vasu-rangpariya-xl
Copy link

vasu-rangpariya-xl commented May 9, 2023

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

@ahunter135
Copy link

I'm also getting this issue like crazy. Would love to see a solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants