Spot the bug in async deliveries

from Array methods
Node 24 intermediate 4 min 1 issue to find

Find why this function returns before deliveries are recorded.

JavaScript
async function sendAll(messages) {
  const delivered = [];
  messages.forEach(async (message) => {
    const result = await send(message);
    delivered.push(result.id);
  });
  return delivered;
}
Open in playground
Report an error