GeoFence analysis hangs at call to function

Hi Everyone

I think my issue is more of a script writing problem rather than a logic problem and i hope someone can help me to move forward.

I have an analysis to check if a location is within a geofence then initiate a notification.
The problem is that the script runs well till it gets to the call checkZones, here it hangs.
Here’s the call:

  >   // Get the geofence meta data and put it into a list
>   const zones = geofence.map((geofence) => geofence.metadata);
>   const geofence_list = zones[0];
>   context.log("geofence_list = ",zones[0]);
> 
> 
>   // Split location into lat long for point
>   const latlong = location[0].value.split(",");
>   //context.log("lat =", latlong[0]);
>   //context.log("long =", latlong[1]);
>   const point = [latlong[1], latlong[0]];
>   context.log("point =", point);
> 
>   //Call the function insideZones to see if the device is in a geofence or not
>   const insideZones = await checkZones(point, geofence_list);

And here’s the function:

  >   // This function checks if our device is inside any geofence
> async function checkZones(point, geofence_list) {
>   context.log('Running checkzones');
>   const insideZones = [];
>   // The line below gets all Polygon geofences that we may have.
>   const polygons = geofence_list.filter((x) => x.geolocation.type === "Polygon");
>   if (polygons.length) {
>     // Here we check if our device is inside any Polygon geofence using our function above.
>     for (const polygon of polygons) {
>         if (insidePolygon(point,  polygon.geolocation.coordinates[0])){
>             insideZones.push(polygon.event);
>         }
>     }
>   }
>   // The line below gets all Point (circle) geofences that we may have.
>   const circles = geofence_list.filter((x) => x.geolocation.type === "Point");
>   if (circles.length) {
>     // Here we check if our device is inside any Point geofence using a third party library called geolib.
>     for (const circle of circles) {
>         if (geolib.isPointWithinRadius
>            ({latitude:point[1],longitude: point[0] },
>             {latitude: circle.geolocation.coordinates[0], longitude: circle.geolocation.coordinates[1] },
>             circle.geolocation.radius)) { 
>             insideZones.push(circle.event);
>         }
>     }
>   }
>   return insideZones;
> }

I would appreciate any help.
Thanks
Steven

Here’s the console output

[2021-02-05 15:59:12] geofence_list =  {"color":"","event":"entering_zone","geolocation":{"coordinates":[-34.12429447233787,18.38298082351685],"radius":429.8821561214525,"type":"Point"},"id":"prUirTWSm"}
[2021-02-05 15:59:12] {}
[2021-02-05 15:59:12] point =  18.3851308,-34.1258448
[2021-02-05 15:59:12] The geofence is :  inside_geo
[2021-02-05 15:59:12] The location is:  -34.1258448, 18.3851308
[2021-02-05 15:59:12] Enviroment Set
[2021-02-05 15:59:12] Running Analysis
[2021-02-05 15:59:12] Starting analysis 601a99a566fd8200113fdcad

Hi i resolved this by removing the calls to the function and writing the function script in the main analysis. Can clean it up later, for now it works this way