This function will eat memory and eventually crash node. Is that the expected behavior or a bug in v8?
async function crash() {
for (let i = 0; i < 10000; i++) {
await Promise.race(new Array(10000));
}
}
I'm guessing every iteration creates 10,000 new tasks but only waits for 1 of them to execute leaving 9,999 tasks behind which will accumulate and fill up the memory. But shouldn't those left behind tasks get executed and therefore be removed from memory once Promise.race is called in the next iteration?