Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

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

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
AI

The AI Prompt That Reviews Your Retry and Backoff Logic for Silent Infinite Loops

- 27.09.26 - ErcanOPAK

🤖 The AI Prompt That Finds the Retry Loop That Never Actually Gives Up

Retry logic with backoff is meant to handle transient failures gracefully – but a subtle bug (a missing maximum attempt count, a backoff calculation that never actually increases, an exception type check that accidentally catches and retries something that will NEVER succeed) can turn well-intentioned retry logic into a silent, resource-consuming infinite loop. This prompt asks an AI assistant to review retry code specifically for that failure mode.

📋 The Prompt

Review this retry/backoff logic specifically for ways it could loop
indefinitely or effectively forever, rather than general code quality.

Check specifically for:
1. Is there a hard maximum number of attempts, and is it actually
   enforced correctly (off-by-one errors in the loop condition count)?
2. Does the backoff delay actually increase between attempts, or could
   a bug make it stay constant or even reset?
3. Is the retry condition (which exceptions/error codes trigger a
   retry) broad enough to accidentally include a PERMANENT failure
   (like an authentication error) that will never succeed no matter how
   many times it'"'"'s retried?
4. If this runs inside a loop or a scheduled/recurring job, could a
   single call'"'"'s retries interact badly with the OUTER loop also
   retrying, multiplying the effective number of attempts far beyond
   what'"'"'s obvious from reading this code in isolation?

For each issue found, describe the specific scenario that would trigger
it and roughly how long/how many attempts it would take before someone
would actually notice something was wrong.

[PASTE THE RETRY/BACKOFF CODE HERE]

✅ Why This Prompt Works

  • Explicitly asking about permanent-vs-transient failure classification catches one of the most common real-world causes of this bug: retry logic that correctly retries a temporary network blip but ALSO retries a permanent 401 Unauthorized or 403 Forbidden that will identically fail on every single attempt, forever.
  • Asking specifically about nested/outer-loop interaction catches a subtler compounding case that’s easy to miss when reviewing retry logic in isolation – a function with its own internal retry, called from within an outer loop that also retries on failure, can produce a MUCH larger effective attempt count than either piece of code suggests on its own.
  • Asking for a rough estimate of how long it would take before someone notices frames the finding in terms of actual operational impact, which helps prioritize whether a given issue is a one-line fix worth doing today or a more involved rework worth scheduling deliberately.

⚠️ Where to Draw the Line

  • This review is about the LOGIC’s structural soundness, not about picking specific retry counts or delay values for a particular system – those numbers depend on context (how expensive is a retry, how long can a caller reasonably wait) that only someone with full operational knowledge of the system can decide.
  • A finding here is worth verifying with an actual test that intentionally triggers the failure condition described, rather than trusting the review’s reasoning alone – retry logic bugs are exactly the kind of thing that benefit from being reproduced concretely before considering them confirmed.

Retry logic is supposed to be the safety net under a flaky system – the version worth worrying about is the one that quietly becomes the thing generating the load, not catching it.

— AI Power User

Related posts:

The AI Prompt That Turns a Flaky Test Failure Into a Ranked List of Likely Root Causes

The AI Prompt That Turns a Flaky Test Failure Into a Ranked List of Likely Root Causes

AI Prompt: Generate Business Plan Executive Summaries

AI Prompt: Generate Business Plan Executive Summaries

The AI Prompt That Walks Through a Stack Trace and a Commit Range to Find Which Commit Actually Intr...

The AI Prompt That Walks Through a Stack Trace and a Commit Range to Find Which Commit Actually Intr...

Views: 9

Post navigation

WordPress: Fix a Login Page That Redirects Back to Itself in an Endless Loop
C#: Fix a Params Array Overload That Silently Binds to the Wrong Method

Leave a Reply Cancel reply

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

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (661)
  • Add Constraint to SQL Table to ensure email contains @ (619)
  • Average of all values in a column that are not zero in SQL (576)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (553)
  • Find numbers with more than two decimal places in SQL (481)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store
  • WordPress: Fix a Navigation Block Losing Submenu Items After Sync
  • Visual Studio: Fix CodeLens Reference Counts Stuck at Stale Numbers
  • C#: Fix a UTF-8 String Literal Behaving Differently in a Switch
  • Photoshop: Fix a Liquify Mesh Snapping Back on a Smart Object
  • The AI Prompt That Turns a Crash Dump Into a Short Repro Script

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store

Social

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