RetryableError

When a RetryableError is thrown in a step, it indicates that the workflow should retry a step. Additionally, it contains a parameter retryAfter indicating when the step should be retried after.

You should use this when you want to retry a step or retry after a certain duration.

import { RetryableError } from "workflow"

async function retryableWorkflow() {
    "use workflow"
    await retryStep();
}

async function retryStep() {
    "use step"
    throw new RetryableError("Retryable!") 
}

The difference between Error and RetryableError may not be entirely obvious, since when both are thrown, they both retry. The difference is that RetryableError has an additional configurable retryAfter parameter.

API Signature

Parameters

NameTypeDescription
optionsRetryableErrorOptions
messagestring

RetryableErrorOptions

NameTypeDescription
retryAfternumber | StringValue | DateThe number of seconds to wait before retrying the step. If not provided, the step will be retried after 1 second.

Examples

Retrying after a duration

RetryableError can be configured with a retryAfter parameter to specify when the step should be retried after.

import { RetryableError } from "workflow"

async function retryableWorkflow() {
    "use workflow"
    await retryStep();
}

async function retryStep() {
    "use step"
    throw new RetryableError("Retryable!", {
        retryAfter: "5m"
    })
}