🤖 The AI Prompt That Finds Unawaited Promises in a Node Script
A Promise that’s created but never awaited, returned, or attached to a .catch() keeps running in the background with nowhere for its eventual rejection to go, and in modern Node that unhandled rejection can crash the whole process. These are easy to introduce — a forgotten await inside a loop, a call left bare as a “fire and forget” that was supposed to be awaited — and just as easy for a human reviewer to skim past, since the code still reads correctly from left to right. This prompt asks an AI assistant to specifically hunt for that one pattern across a file instead of reviewing everything at once.
🔎 The Problem
A human review pass naturally reads code top to bottom for logic, not for the one missing keyword that turns a safe async call into a background promise nobody is watching. That’s exactly the kind of narrow, repetitive check an AI assistant can run far more exhaustively than a quick read-through allows.
💬 The Prompt to Use
Review the attached Node.js file and find every Promise-returning call that is neither awaited, returned, nor followed by a .then()/.catch(). For each one you find, report: 1. The exact line and the function it's inside 2. Whether it's inside a loop (so the issue repeats per iteration) 3. Whether an uncaught rejection there would crash the process or just silently vanish, based on whether it's top-level or inside an async function with its own surrounding error handling 4. A one-line fix: add `await`, return the promise to the caller, or attach an explicit `.catch(...)` if fire-and-forget is intentional Do not flag promises that are already handled further down the same chain, and do not suggest converting intentional fire-and-forget calls to synchronous ones - just make sure each has an explicit `.catch()`.
💡 Tips for Using This Prompt
- Point it at one file or module at a time rather than a whole repo, so the output stays short enough to actually act on instead of a long list you’ll skim past.
- Ask it to separate “inside a loop” findings from one-off calls first, since a missed await inside a loop usually means the iterations are racing each other instead of running in the order you expect.
- Treat every “intentional fire-and-forget” finding as a prompt to add an explicit .catch(), not to leave it alone — intentional and unhandled aren’t the same thing.
🚨 Why This Matters
- An unhandled rejection that only happens on a rare error path (a flaky network call deep in a loop, say) can pass every normal test run and then take the whole process down the first time it hits production traffic.
A promise you don’t wait for doesn’t stop running — it just stops being yours to hear from when it fails.




