---
url: https://listr2.kilic.dev/task/retry.md
---

# {{ $frontmatter.title }}

If you want to retry a task that had failed a couple of times more, you can use the `retry` property in the `Task`.

::: info Example

You can find the related examples [here](https://github.com/listr2/listr2/tree/master/examples/task-retry.example.ts).

:::

## Usage

<<< @../../examples/docs/task/retry/basic.ts{18}

## Retry Delay

Retry action can have a delay between the tries. For enabling this behavior, you can pass the retry to the given task as an object.

<<< @../../examples/docs/task/retry/retry-delay.ts{18-21}

While waiting between attempts the task enters a paused state, and the *DefaultRenderer* shows a live countdown until the next try through its `pausedTimer` option. You can check for this state inside a task with `task.isPaused()`.

## Retry Event

Retrying is self-aware, and you can access the task if it is retrying via `task.isRetrying()`. It will either return an object [with the given interface](/api/listr2/interfaces/ListrTaskRetry.html) where the `count` will be `0` for not repeating tasks, and `error` is the last encountered error if retrying.

### Retry Count

<<< @../../examples/docs/task/retry/retry-count.ts{8,10-13}

### Last Error

<<< @../../examples/docs/task/retry/last-error.ts{8,10-13}

## Renderer

* When retrying, the task title will be reset to the original task title.

### *DefaultRenderer*

### *SimpleRenderer* & *VerboseRenderer*

The non-TTY renderers log a `RETRY` entry with the current attempt count on each retry, rather than resetting an in-place title.
