Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
AI

The AI Prompt That Finds Unawaited Promises in a Node Script

- 29.11.26 - ErcanOPAK

🤖 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.

— AI Power User

Related posts:

AI Prompt: Generate Blog Post Outlines

AI Prompt: Generate Blog Post Outlines

The AI Prompt That Reviews Your Feature's Rollback Plan Before You're the One Explaining Why There W...

The AI Prompt That Reviews Your Feature's Rollback Plan Before You're the One Explaining Why There W...

The AI Prompt That Checks Whether Your Test Suite's Tests Secretly Depend on Running in a Specific O...

The AI Prompt That Checks Whether Your Test Suite's Tests Secretly Depend on Running in a Specific O...

Views: 5
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

SQL Server: Fix a Window Function Re-Sorting an Already Sorted Input
Docker: Fix a Healthcheck Interval Too Slow to Catch a Crash Loop

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,080 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 672 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 585 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com