I Have NodeJS post route like that:
const Sleep = async (milliseconds) => {
await new Promise(resolve => setTimeout(resolve, milliseconds));
}
app.post("/read_x2", async (req, res) => {
while (true) {
var done = false;
await Sleep(1000);
// await mysqlconnection // if found: done = true;
if(done) {
return;
}
await Sleep(1000);
}
}
})
the post route is like: https://sub.domain.com/read_x2
when i do post to that url, it should wait for sql to be done, time is unlimited to wait, maybe wait 1 sec and maybe 10 minutes, anyway when i do post request, after some time (less than minute) request automatically redirected to main domain https://sub.domain and got results despite Node code still waiting mysql to be done
What is the reason of this issue and how to solve it ?