Does Array.fromAsync Run Sequentially? Check Where Work Starts
Contents
For a plain array of inputs, Array.fromAsync(ids, work) calls work for one item and waits for its result before calling it for the next. Move the same function into Array.fromAsync(ids.map(work)), and all the calls start during map, before Array.fromAsync receives the promises.
The difference matters when you’re replacing Promise.all(ids.map(work)) to stop operations from overlapping. Changing the collector alone leaves the starts where they were.
Trace where each operation starts
Save this as trace.mjs and run node trace.mjs in a runtime with Array.fromAsync. The callback records its start, yields once to the promise queue, then records its end. The assertions check both the final values and the call order.
import assert from 'node:assert/strict';
const ids = [1, 2, 3];
async function trace(collect) { const events = []; const result = await collect(async (id) => { events.push(`start ${id}`); await Promise.resolve(); events.push(`end ${id}`); return id * 10; }); assert.deepEqual(result, [10, 20, 30]); return events.join(', ');}
const serial = 'start 1, end 1, start 2, end 2, start 3, end 3';const eager = 'start 1, start 2, start 3, end 1, end 2, end 3';const cases = [ ['fromAsync mapper', (work) => Array.fromAsync(ids, work), serial], ['Promise.all + map', (work) => Promise.all(ids.map(work)), eager], ['fromAsync + map', (work) => Array.fromAsync(ids.map(work)), eager],];
for (const [label, collect, expected] of cases) { const observed = await trace(collect); assert.equal(observed, expected); console.log(`${label}: ${observed}`);}fromAsync mapper: start 1, end 1, start 2, end 2, start 3, end 3Promise.all + map: start 1, start 2, start 3, end 1, end 2, end 3fromAsync + map: start 1, start 2, start 3, end 1, end 2, end 3All three calls return [10, 20, 30]. That array alone can’t tell you whether work overlapped. In the first trace, end 1 comes before start 2 because the Array.fromAsync algorithm awaits the mapper result before moving to the next item. In the other two traces, map calls the callback while building its array. The collector receives the returned promises after those calls have started.
Put the start inside the mapper
If work must run one item at a time, pass the original inputs and the function separately: await Array.fromAsync(ids, work). Make sure work returns the promise for the entire operation. If it starts background work and returns early, the next mapper call can start before that background work finishes.
If the tasks can all overlap, await Promise.all(ids.map(work)) expresses that choice directly. For a loop with early exits or per-item error handling, use an awaited for…of loop.
The trace ran on Node.js 24.13.0 on macOS arm64 with a plain array and simulated async work. It verifies call order, without measuring network throughput or testing browser support.
References: ECMAScript: Array.fromAsync, ECMAScript: Array.prototype.map, ECMAScript: Promise.all. Checked November 13, 2026.