App stuck in an infinite loop

My App is stuck in an infinite loop it seems, its a node based hello-sqllite type project. This started around 5 am Central Time in US.

I see that in the past, Glitch had an outage when this sort of a behavior was exhibited but now the status page is showing everything operational and my app is still stuck in an infinite loop.

I am not ruling out an infinite loop in my server.js, as I am new to node.js coding and an trying read files in one of the API calls using async D3 functionality to read csv files.

In any case, I would like to know that where the problem is, in my server.js or on glitch.com services.

Here is a snippet of code from server.js:

app.post("/loadHalos", (request, response) => {
async function read_orbit_data(
csv_file_url,
scale_factor,
yoffset,
zoffset,
csvData
) {
function getData(csvRow) {
csvData.push(
new THREE.Vector3(
parseFloat(csvRow.x) * scale_factor,
parseFloat(csvRow.z) * scale_factor + yoffset,
parseFloat(csvRow.y) * scale_factor + zoffset
)
);
}
await d3.csv(csv_file_url, function(data) {
getData(data);
});
console.log(csvData[0]);
};
let scale_factor = request.body.scale_factor;
let yoffset = request.body.yoffset;
let zoffset = request.body.zoffset;
let halo_files = fs.readdirSync(assertsFolder);
let halos_read = new Array();
var j=0;
for (j=0; j < halo_files.length; j++) {
halos_read.push(false);
}
var i = 0;
if (halos === undefined) {
halos = new Array();
}
try {
halo_files.forEach(filename => {
halos.push(new Array());
read_orbit_data(filename, scale_factor, yoffset, zoffset, halos[i]).then(
() => {
halos_read[i] = true;
}
);
while (!halos_read[i]);
i += 1;
});
} catch (err) {
console.log(err);
response.send({ message: “error!” });
}
response.send({ message: “success” });
});

Thanks for your help in advance…

Do you have any errors in the logs?

No errors in the logs, logs indicate the app dependencies installation successful, I included some log messages of my own to see the behavior, it’s printing my custom log messages infinitely.

I would recommend that you reach out to support@glitch.com and they can hard restart your project. That might sort out some of the errors.

Thanks :slight_smile: I will do that…

1 Like