Skip to content

Taxonomy

Unawaited promise

The work was started and nobody waited for it.

What it looks like

  • A missing await on a call whose result is not used.
  • array.map(async …) passed somewhere expecting values rather than promises.
  • A forEach with an async callback.

Why it survives review

Nothing about the line looks wrong, and TypeScript will often not complain when the result is discarded. The function returns promptly and correctly; the write it was supposed to perform lands a moment later, or not at all, and its failure becomes an unhandled rejection somewhere with no stack trace worth reading.

How to see it

  1. Read every call in an async function and ask whether it returns a promise. If it does and there is no await, decide whether that is deliberate.
  2. forEach cannot await. Any async callback passed to it is fire-and-forget.
  3. Check what happens to the rejection. Work nobody awaited is work whose failure nobody sees.

A minimal pair

Correct

await saveOrder(order);
return { ok: true };

Defective

saveOrder(order);
return { ok: true };

The response says the order was saved before the save has happened — and if it fails, it says so anyway.

Practise it

No exercise in the corpus sets this class yet. The lesson stands on its own — the corpus grows by adding subjects, and pretending otherwise would hide the gap.