Skip to content

Retry ​

The Retry block runs a chain of blocks and, if that chain fails with an error, runs it again. Use it for steps that sometimes fail for a moment and then work, like a call to a busy API.

When to use it ​

  • Call an external service that sometimes times out or returns an error.
  • Read from something that may not be ready yet, and wait a little before trying again.
  • Don't use it for errors that will never go away, like a wrong URL or bad input. Every try fails the same way.

Retrying a write can run it twice

Each try runs the whole chain again. If the chain inserts a record or sends a payment request and then fails on a later block, the next try does that write again. Keep writes idempotent (safe to repeat), or keep them out of the retried chain.

Inputs ​

FieldRequiredDefaultWhat it does
Executor (top handle)YesnoneConnect the first block of the chain to retry. It gets the Retry block's input on every try.
Retry type (Delay tab)NoFixed delayHow long to wait before each new try. See Retry types.
Max retriesNo3How many more times to try after the first one. From 1 to 10, so the chain runs at most 11 times.
Delay (ms) (Delay tab)No1000The starting wait, from 0 to 30000. Not used by Immediate.
Max delay (ms) (Delay tab)No30000The longest any single wait can be, from 0 to 30000.
Save output to variableNooffStore the result of a successful try in outputs.<name>.

Outputs ​

HandleRuns whenInput to the next block
Success (right)A try finished without an error.The last output of the Executor chain.
Failure (right)Every try failed.{ attempts, message }
Executor (top)On every try.Connect the chain to retry.
  • attempts is how many times the chain ran, the first try included.
  • message is the error text of the last try.

Retry types ​

With a Delay of 1000, the waits before each retry are:

Retry typeWhat it doesRetry 1Retry 2Retry 3
ImmediateNo wait.000
Fixed delayThe same wait every time.100010001000
Linear backoffThe wait grows by Delay each time.100020003000
Exponential backoffThe wait doubles each time.100020004000
Exponential backoff + jitterA random wait between 0 and the exponential one.0 to 10000 to 20000 to 4000

No wait is ever longer than Max delay.

Which one to pick

Use Exponential backoff + jitter when many requests may fail at the same moment, for example when a shared service goes down. The random waits spread the retries out, so they don't all hit the service again at once.

Example: call a flaky API ​

Entrypoint → Retry (Exponential backoff + jitter, Max retries 3, Delay 500)
               ├─ executor → HTTP Request (GET https://api.example.com/rates)
               ├─ success  → Response 200   (input: the API's response)
               └─ failure  → Response 503   (input: { attempts: 4, message })

If the API fails, the block waits and calls it again, up to 3 more times. When it works, the caller gets the rates. When every try fails, the caller gets a 503.

How it behaves ​

  1. The block runs the Executor chain.
  2. If the chain finishes without an error, it continues on Success.
  3. If a block in the chain throws an error, it waits (see Retry type) and runs the chain again.
  4. When the chain has failed Max retries more times, it continues on Failure.
  • If a block in the executor chain sends a Response, that response is returned right away. That is not an error, so nothing is retried.
  • The wait does not hold up other requests. Only this run waits.
  • Every failed try still shows in the logs and traces, so you can see why it failed.

When nothing is connected to Failure ​

The last error fails the run, as with any other block, so the Error Handler still receives it.

Inside a database transaction ​

A Rollback Transaction block or a transaction timeout inside the executor chain is not retried. It stops the transaction as usual.

On PostgreSQL, a failed query breaks the whole transaction, so retrying inside one cannot recover. Put the Retry block around the DB Transaction instead, so each try gets a fresh transaction.

Released under the Apache License 2.0. Enterprise features are under the Fluxify Enterprise Edition License.