Member-only story
Array.fromAsync vs Promise.all: Same Array on a Good Day, a Crashed Node Process on a Bad One
Array.fromAsync awaits one value at a time. That makes it right for pages and streams, and risky for requests you already started.
Santosh Yadav
12 min read5 hours ago
Press enter or click to view image in full size
Wrap this in a try/catch and it looks safe:
try {
const users = await Array.fromAsync(ids.map(fetchUser));
render(users);
} catch (err) {
showError(err);
}
Now let the second request fail fast while the first one is still loading. On Node 26.13.1 the process exits with code 1 and the catch block never runs. Change Array.fromAsync to Promise.all and the same failure lands in the catch 23 ms in.
That difference is what this post on Array.fromAsync vs Promise.all is about. Both turn a list of async work into one array, and when everything succeeds they hand you the same result. They differ in when they start listening.…