Skip to main content
When an uncaught error is thrown inside your task, that attempt fails. Trigger.dev will then retry the task according to your configured retry settings. You can configure retrying in two ways:
  1. In your trigger.config file — sets the default for all tasks.
  2. 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 the retry field:
/trigger/task-with-retries.ts

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