Affarit StudioFree audit
Back to blog

What Happens If Your Automation Runs Twice?

A customer fills in your order form. The page hangs. They click Pay again. Your automation now holds two identical requests and has to decide what to do with the second one. If nobody made that decision before launch, it can charge twice, send two confirmation emails and create two orders.

Repeats are expected, even if they are not frequent: people double click, senders redeliver, platforms retry or replay, and a lost connection can hide whether the first attempt worked at all. So our rule is short: before launch, every step that sends, charges or creates something needs a way to tell it has already been done.

The documentation says repeats happen

A step can run twice even when nothing looks wrong.

  • The GOV.UK Design System notes that people sometimes double click buttons, out of habit, on a slow connection with no feedback, or because of a motor impairment, and the information can be sent twice. Its option to ignore the second click works only with JavaScript, and it says to handle the problem on the server too.
  • Stripe says its webhooks, the messages it sends to your system, may occasionally arrive more than once. In live mode it retries delivery of an event for up to three days, and events can also be resent by hand.
  • Amazon's standard message queues can, on rare occasions, deliver a message again. AWS tells developers to design so that processing the same message twice does no harm.
  • AWS Lambda, for calls that don't wait for an answer, by default runs a function two more times if it returns an error, timeouts included. It can also receive the same event several times without any error.
  • In Zapier, replaying an entire Zap run replays every step, the trigger and all previous steps included. Replaying only the errored steps is a different action.

If your workflow takes input from a form with a button, or runs on any of the tools above, a second run is part of the design whether you planned for it or not.

An error does not mean nothing happened

The tempting fix is to retry blindly whenever something fails, with no way to recognise the operation. That is where the damage starts. When a connection drops, the sender may not know whether the other side received or carried out the request, and getting the connection back does not tell you either. Stripe is explicit: an error 500 does not prove nothing happened. The operation might have had effects.

Engineers call a step that is safe to repeat idempotent: doing it twice has the same intended effect as doing it once. Many requests are not like that. MDN's example is a request that adds a row: send it several times and you get several rows. The HTTP standard says a client should not retry such a request automatically unless it knows the request is safe to repeat, or that the original never applied.

Give each operation a name it can be recognised by

Amazon's engineering library warns that simply retrying a request that creates something can create it more than once. The fix it prefers: the caller supplies a unique request identifier, so a retry has no additional side effects. Stripe calls these idempotency keys. Repeat a request with the same key after a connection error and it will not create a second object or run an update twice.

  • Stripe suggests deriving the key from something like a shopping cart ID, a simple guard against double submissions. If retries span separate calls or restarts, create the key once, save it and send it with every attempt.
  • For incoming webhooks, Stripe suggests logging the IDs of events already processed and skipping any that show up again. Sometimes it sends two separate events for one change; spot those by the underlying object's ID together with the event type.
  • A unique rule in the database can refuse a second row with the same identifier. Watch the gap: by default, PostgreSQL does not treat two null (missing) values as equal, so rows with no identifier are not blocked.

Every guard has edges. In Stripe's v1 API, keys can be removed once they are at least 24 hours old, and reusing a removed key can run a new request. n8n's Remove Duplicates node remembers a limited history, 10,000 items by default in its Value Is New mode. Zapier's built-in duplicate check is documented for polling triggers (the ones that check an app for new items), not for every step.

Test it by sending the same thing twice

Here is the method we use. List the steps where a repeat would hurt: anything that sends, charges or creates. In a test setup, send the same input twice and count what was sent, charged or created. It passes if the second send adds nothing: each message, charge and record that one request should produce appears once, and no more.

Where a step fails, ask your builder for a specific check, not a general promise. Five questions get you there:

  • What identifies this operation?
  • Where is that identifier saved?
  • What happens on the second attempt?
  • How long is it remembered?
  • What happens if the outcome is unknown?

One passing test is not proof for every case. Two copies arriving at the same moment, or a repeat after the key or the history has expired, are separate tests. And a new key is not a way around an unknown outcome: Stripe says to find out what happened to the original before retrying with a new one.

An automation is not ready until it knows what it has already done. If you want a second view on where your systems stand, take our 3-minute free audit. We'll send a tailored read on where you are, what to focus on, and whether Affarit is the right fit.

Free audit

Found this useful?

Tell us about your business, and we'll point you at the highest-leverage place to start.