with.retry
· Retry policy
The retry policy defines how a step should be retried in case of failure.
- _: Say hi
log: Bonjour, mes amis !
with:
retry:
if: ${error.response.status === 429}
attempts: 3
delay: 5 seconds
IMPORTANT
A step is always retried with the same exact context, which means that properties are not templatized again (unless mentioned otherwise).
with.retry.attempts
The number of additional attempts to perform in case of execution failure (excluding global context abortion and global context timeout). The initial attempt is not included in this limit (which also means the total number of execution attempts may be up to retry.attempts + 1
)
- with:
retry:
attempts: 2
TIP
Use Infinity
to retry indefinitely.
TIP
Using retry: <value>
with a numeric value (or Infinity
) is a shorthand for retry: { attempts: <value> }
.
- with:
retry: 2
with.retry.delay
- Retry in-between delay
The delay to wait between each attempt.
This property is evaluated on each retry attempt.
- with:
retry:
delay: "${error.response.status === 429 ? 60 : 5 } seconds"
WARNING
When using with.timeout.global
, the delay between retries is included in the overall timeout duration.
with.retry.if
- Retry condition
A templated expression evaluated after each failed attempt and which schedule a new attempt on any truthy value. If the expression is falsy, no further attempts will be made (even if the maximum number of retry attempts has not been reached).
This property is evaluated on each retry attempt.
WARNING
Using retry.if
without retry.attempts
explicitly defined in the context tree implies retry.attempts: Infinity
.
- with:
retry:
if: ${error.response.status === 429}
TIP
Using retry: <value>
with a string value (or literal false
) is a shorthand for retry: { if: <value> }
. Note the use of a backslash to escape the expression and prevent the templating engine to evaluate it as the value of the whole retry
policy object.
- with:
retry: \${error.response.status === 429}
CAUTION
The whole context execution will error out if the evaluation of the condition throws, and no further attempts will be made.