'Is there a way native javasacript way to prevent excessive memory usage without await in loops?

I see that ES Lint is discouraging the use of await in loops, but I don't see any other native-language based option to prevent randomly excessive memory usage when the process inside the loop requires a lot of memory.

I understand that this could be prevented with the use of promise queues, but those have to be implemented or imported in a library.

Why are they promoting this kind of reckless use of memory and resources?

If I run all the processes "at once" with Promise.all() when each process can consume a highly random amount of memory, and there could be a huge amount of items to process, the script will likely crash, wouldn't it?

Or can you confirm if when using Promise.all() javascript will handle the memory properly to ensure that the memory is not exhausted by running all processes at once?

And what if the process opens network connections and have millions of items to process? I can easily hit the maximum network connections of the OS, and would have to put in place more mechanisms to queue those.

Why is it so wrong to use a simple await in a loop? They say the only reasonable reason for using awaits in a loop is when the iterations need information from each other, but just to prevent excessive resource consumption seems reasonable enough to me, isn't it?

Is there an alternative language-native way to run asynchronous heavy processes over a large list of items without risking excessive resource consumption?

Am i misunderstanding the ES Lint recommendations?

Here is the link: https://eslint.org/docs/rules/no-await-in-loop



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source