- In your
trigger.configfile — sets the default for all tasks. - On each individual task — overrides the default for that task.
By default, the CLI init command disables retrying in the
DEV environment. You can enable it in
your trigger.config file.Retry configuration
Set retry options on a task using theretry field:
/trigger/task-with-retries.ts
| Option | Description |
|---|---|
maxAttempts | Maximum number of attempts before the run fails. |
factor | Exponential backoff factor applied to each retry delay. |
minTimeoutInMs | Minimum delay between retries in milliseconds. |
maxTimeoutInMs | Maximum delay between retries in milliseconds. |
randomize | Adds jitter to the retry delay to avoid thundering herd. |
Combining tasks for reliability
Breaking work into smaller tasks gives each piece its own retry budget and lets you view and retry each part independently from the dashboard:/trigger/multiple-tasks.ts
Retrying parts of a task
retry.onThrow()
Retry a specific block of code with its own retry settings. If all attempts fail, an error is thrown:
/trigger/retry-on-throw.ts
retry.fetch()
Make HTTP requests with automatic retrying based on the response status or timeout:
/trigger/retry-fetch.ts
Advanced error handling with catchError
The catchError callback is called when an uncaught error is thrown inside run. Use it to inspect the error, modify retry behavior, or skip retrying entirely.
If you do not return anything, the task’s default retry settings are used.
OpenAI error handling example
OpenAI errors require different handling depending on the reason for failure:Preventing retries
AbortTaskRunError
Throw AbortTaskRunError to fail the run immediately without retrying:
/trigger/openai-task.ts
Using try/catch
Catch errors yourself to implement fallback logic without triggering a retry:/trigger/openai-with-fallback.ts