📝 The gotchas of unhandled promise rejections, and how to work around them.

https://jakearchibald.com/2023/unhandled-rejections/

The gotcha of unhandled promise rejections

A rough edge with promises that can sneak up on you.

@jaffathecake
I may be wrong, but I don't think that's how "await for of" behaves in this situation. You're passing in an array of promises, it's going to wait for every one of them to resolve before running the actual loop. I think you're thinking of running new promises inside the loop, but that runs the risk of getting stuck behind a long chapter load. Right?
@mostlyfocusedmike you are wrong 😀. "For await" awaits each promise, in turn, before each iteration of the loop. It sounds like you're suggesting it waits for all promises before the first iteration. That isn't how it works. Try it.
JS Bin

A live pastebin for HTML, CSS & JavaScript and a range of processors, including SCSS, CoffeeScript, Jade and more...

@jaffathecake ahh, I get it, my problem was I blocked it FIRST, so that's why it looked like identical. I see how in yours 1 and 2 work and then 3 and 4 are both 400 because it gets blocked.

Ok so that's really cool, it fires them all off at once, and then IF they're ready, gives you the order. So at worst it's only promise.all, but you can get little speed boosts.

I typically just use allSettled (for the rejection reasons you talk about) so I don't use the loop much, but it's handy to know!