Could someone help me understand what's happening under the hood here? I'm trying to determine if there's a point at which the below code breaks?
The point is to execute as many function calls as I can as I'm waiting on a response from a remote endpoint that I'm simulating here using setTimeout.
I'm sure there's a limit on how many functions I can invoke this way - the question being, will NodeJS queue them for me, or do I have to chunk them myself? Should I do loops of 1,000 at a time, or 10,000 at a time, etc.?
function theInvocation() {
return function() {
setTimeout(() => { console.log('Test!'); }, 2000);
}
}
(() => {
for (let ctr = 1; ctr < 1000; ctr++) {
theInvocation()();
}
})();