Appngen · Guide
An API timeout doesn't mean the call failed
Why a timed-out request can still have done its work, why retrying it blindly is how duplicate invoices happen, and how to settle it properly instead.
Published · About an 8 minute read
What a timeout actually tells you
You sent a request and stopped waiting for the answer. That is all a timeout says. Behind it is one of three situations:
- The request never arrived. A connection dropped before the other system saw it. Nothing happened.
- It arrived, ran, and the reply was lost. The invoice exists, the charge went through, the email was sent. Only the confirmation is missing.
- It is still running. The other system is slow and will finish after you have stopped listening.
From the caller's side these are indistinguishable. Treating all three as "failed" is the mistake.
Why retrying blindly goes wrong
Most automation tools retry a failed step a few times. For a read, that is fine. For a write it means that in the second situation above — the work was done, the reply was lost — the retry does it again. A second invoice. A second card charge. The same customer emailed twice.
Not retrying is no better. In the first situation nothing happened, and a workflow that gives up leaves a lead with no follow-up or an order with no invoice, often without anyone noticing.
Exactly-once is not on offer
No tool can promise that an action happens exactly once in a system it does not control, over a network that can drop any message. Anyone who claims it is describing the good days. What can be done is to make the uncertain moment safe, with one of two tools.
Tool one: let the other system collapse repeats
Some APIs accept an idempotency key: a unique value you send with the request, often in an Idempotency-Key header. If the same key arrives twice, the API returns the first result instead of doing the work again. Payment APIs commonly work this way. When an API offers this, retrying is safe without any further checking — as long as every retry of the same action reuses the same key.
Tool two: check before repeating
When the API offers no such key, put one in the record instead: a unique value stored with the invoice, the contact or the row. After a timeout, look the record up by that key before doing anything else.
The catch is that not every lookup can prove a negative. A database queried by an exact key can: if the row is not there, the write did not land. A search index or a mailbox listing often cannot — the record may exist but not be visible yet. So a lookup has three possible answers, not two:
- Found. The action happened. Use its result and do not repeat it.
- Provably absent. The action did not happen, and the lookup is strong enough to say so. Doing it once is safe.
- Can't tell. The lookup missed but is not proof, or the lookup itself failed. Neither retrying nor giving up is safe, so a person has to decide.
A lookup that errors out is always "can't tell". A broken check says nothing about whether the write landed.
How Appngen settles a timed-out step
Every step that changes something in another system goes through the same sequence:
- Write down the intent first.Before the call, the engine durably records what it is about to do and a key unique to this step's attempt. A crash after this point cannot lose track of the action.
- Make the call, carrying the key.Where the system supports it, the key goes where that system can find it later: an email header, a CRM property, a request header the API deduplicates on.
- If the outcome is unclear, look it up.Found: the result is used and nothing is repeated. Provably absent: the action is done once, and the run carries on with nobody involved.
- If it still can't tell, stop and say so.The run stops at that step. The step is marked as uncertain, a state of its own rather than an ordinary failure, and the workspace's owners are emailed a link. They check the other system, then retry the step or continue past it.
How far step 3 can go depends on the other system, and Appngen says which it is for every connector rather than assuming the best. A MySQL update with a lookup query can prove absence. A Gmail send or a Google Sheets row append cannot be looked up with the access Appngen asks for, so an uncertain one always goes to a person. The full list is on the integrations page.
Your own API: you declare how far it can be checked
An HTTP step has no fixed answer, because only you know what your API can do. Every call carries the attempt's key in an X-Appngen-Effect-Key header. If your API stores it, tell the step how to look it up:
do:
uses: billing_api
method: POST
path: /v1/invoices
# Your API collapses repeats of the same key: retries are safe as they are.
idempotencyKeyHeader: Idempotency-Key
# Or: look the write up by its key after a timeout.
probe:
path: /v1/invoices/by-key/${effectKey}
# Only if a 404 here truly proves the invoice was never created.
absenceIsProof: true- No probe: an uncertain call always stops for a person. Honest, and the default.
- A probe: a hit is used, a 404 is "can't tell". It prevents duplicates but never authorises a resend.
- A probe with absenceIsProof: a 404 counts as proof, so the engine may retry on its own. Only set it when that is true of your API.
- idempotencyKeyHeader: name it only if your API really deduplicates on that header. The
X-Appngen-Effect-Keyheader on its own is for tracing, not deduplication.
The same problem, arriving
Timeouts happen in the other direction too: a system sending you a webhook does not get your reply in time and sends it again. Appngen keys each delivery on an Idempotency-Key header or an id already in the payload, such as an order number. A repeat returns the original run instead of starting a second one, and is noted on that run's timeline. The same key with different content is rejected rather than silently dropped.
A checklist for any automation
- For each step that writes, decide what a repeat would cost.
- If the API takes an idempotency key, send one, and reuse it on every retry of the same action.
- Otherwise store a key in the record, and know whether a lookup by it can prove absence.
- Treat a failed lookup as "can't tell", never as "not there".
- Make "can't tell" reach a person, with enough context to decide quickly.
Questions
- If an API call times out, did it fail? Not necessarily. A timeout means the reply did not arrive in time. The request may never have arrived, may have been processed with the reply lost on the way back, or may still be running. From the caller's side the three look the same.
- Is it safe to retry a request that timed out? Only if a repeat is harmless. Reads are safe to repeat. A write is safe to repeat if the API deduplicates on a key you send, such as an Idempotency-Key header, or if you can look the write up by a key and prove it is not there. Otherwise a retry can create a second invoice, charge or email.
- Can a workflow tool guarantee exactly-once delivery? Not for anything that crosses a network to a system it does not control. What can be guaranteed is narrower: a repeat is either collapsed by the other system or preceded by a check, and when neither is possible the uncertainty is reported to a person instead of guessed at.
- What does Appngen do when a step times out? Before the call it records what it is about to do and the key it will use. After a timeout it looks the action up in the other system. Found: it uses that result and does not repeat the action. Provably not there: it does the action once, with no person needed. Can't tell, including when the lookup itself fails: the run stops and the workspace's owners are emailed a link to it.