I have a auto-created JS file. And my module call it, some time the auto-created JS file cause infinite loop. And i will call thousand of auto-created JS file, some will run correct but some will cause infinite loop and I will don't know about file content
==> I wonder how I can handle this ?
Example of auto-created JS file. It name "excute.js"
const excuted = (a,b) => {
let i = 0;
while(a<b){
i++;
}
console.log(i);
}
module.exports = excuted();
Example My module ==> i want handle infinite loop error here
const {exec} = require("child_process");
const check = () => {
exec('node excute.js', (error, stdout, stderr) => {
if(error) {
console.log(error.message);
return;
}
console.log(stdout);
})
}
check();
I'm thinking about use setTimeout inside my module file or auto-created JS file. But i really get stuck and confused !!!. Thank every one