DEV Community

Haripriya Veluchamy
Haripriya Veluchamy

Posted on

Why Clicking "Retry" Is Safe Sometimes, and Dangerous Other Times

You've done this before: you're transferring money on a banking app, the screen freezes for a second, and you don't know if it went through. What do you do?

Most people's gut instinct is to click again. "Maybe it didn't send the first time." And most of the time, that's completely fine.

But every now and then, you've heard the horror story someone clicked twice, and the money left their account twice. That's not bad luck. That's a real gap in how the system was built, and it's worth understanding why it happens, because it applies to way more than banking apps.

Why retrying feels safe

When you ask an app to do something check your balance, search for a product, load a page and it fails or hangs, retrying is harmless. You can ask "what's my balance" a hundred times, and nothing changes because of it. You're just asking, not doing.

This is why most systems are built to automatically retry when something goes wrong. A request times out, the system quietly tries again in the background, and you never even notice. This is good design, most of the time.

Why retrying isn't always safe

The trouble starts with actions that actually do something send money, place an order, submit a form. Here's the part people miss:

A failure doesn't always mean the action didn't happen. Sometimes it means you just didn't hear back.

Think about it step by step:

  1. You tap "send money."
  2. The request reaches the bank. The bank actually sends the money.
  3. On the way back, the "success" message gets lost bad network, server hiccup, whatever.
  4. Your screen just... freezes. From where you're sitting, it looks exactly like the request never went through.

If the system (or you) retries at this point, assuming step 2 never happened, you just sent the money a second time. The action did happen. You just never got told.

This is the actual gap not carelessness, not bad luck. It's the simple fact that "I didn't get a reply" and "it didn't happen" are two different things, and a plain retry can't tell them apart.

The fix: give every action a fingerprint

The real fix isn't "don't retry." Retrying is still the right instinct you just need a way for the system to recognize "wait, I've already done this one" before it does it again.

The common way to do this: attach a unique ID to the action itself, generated once, before you even send it the first time. Something like a random code you create on your side and attach to the request "this is attempt number xyz123 of send-money."

Now, if the same request arrives twice (because of a retry), the receiving system checks: "have I already processed xyz123?" If yes, it just replies "already done, here's what happened" instead of doing it again. If no, it processes it normally.

This one idea has a name in tech idempotency which sounds complicated but just means: doing something once, or doing it five times by accident, gives you the exact same end result.

A simple way to picture it: imagine writing your name on a form versus adding a rupee to a piggy bank. Writing your name five times doesn't change anything same name, same result, every time. Dropping a rupee in five times gives you five rupees. The first is naturally "idempotent." The second isn't, unless you specifically design it to be for example, by numbering each rupee and refusing to accept the same number twice.

The simple rule to remember

Before adding automatic retries anywhere, ask one question:

"If this exact same action runs twice by accident, is that okay?"

  • Checking something, reading something, searching something? Almost always yes retry freely.
  • Sending money, placing an order, submitting something that changes real data? Not automatically you need that fingerprint check first.

The takeaway

Retries are one of the most useful tools for making a system feel reliable most failures really are just temporary blips, and quietly trying again is the right call. But retries are not a free upgrade you can bolt onto anything without thinking. The moment an action does something instead of just asking something, you owe it a way to recognize its own repeats otherwise, "just retry" quietly turns a small network hiccup into a real, hard-to-undo mistake.

Top comments (0)