Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
What awaiting actually does
card 5 of 6
TS: the work runs, the error escapes
The agent writes `try { sendReceipt(order) } catch (e) { log.error(e) }` and then `res.json({ ok: true })`. Because `sendReceipt` is async, the email request starts, but the response goes out before it finishes. If its promise rejects (fails with an error), the `catch` never runs, because the `try` block ended long before. The failure becomes an unhandled rejection. Since v15, Node crashes the process on these by default. Browsers only log them. Tell: an async call inside `try` with no `await`. Later cost: the client is told "ok" while receipts silently fail, nothing is logged, and in Node the server can crash. BETTER: `await sendReceipt(order)` inside the `try`.
Terms on this card
- promise
- In JS/TS, an object for work already started that will later resolve with a value or reject with an error.
- await
- Keyword that pauses the current async function until the given work finishes, then returns its value or throws its error at that line.
- rejection
- A promise finishing with an error instead of a value.
- unhandled rejection
- A promise rejection with no handler attached. Node crashes on it by default since v15. Browsers log it to the console.
- Node
- Node.js, the runtime that runs JavaScript/TypeScript outside the browser, typically on servers.
Lesson goal: Explain promises, futures and coroutines and what happens when one is never awaited. In Python the coroutine never runs. In Rust the future is lazy and does nothing. In JS/TS the work runs but its failure goes unobserved and ordering is lost. ·
the whole lesson