---
name: riverpod-retry-12f3e34d85c2
description: Customize Riverpod automatic retry on provider failure; retry function, per-provider and global retry, disabling retry, ProviderException, awaiting retries. Use when a provider can fail transiently and should retry, or when you need to disable or customize retry logic. Use this skill when the user asks about retry, failed providers, or exponential backoff in Riverpod.
---

# Riverpod — Automatic retry

## Instructions

Riverpod **retries** providers when their computation throws. Retry can be customized per provider or globally.

### Default behavior

By default a provider is retried up to a limit (e.g. 10 times) with exponential backoff (e.g. 200ms to 6.4s). **Error** and **ProviderException** are not retried: Error indicates a bug; ProviderException means a dependency failed, so the dependent provider is not retried (the underlying one is).

### Custom retry function

A retry function has signature `Duration? Function(int retryCount, Object error)`. Return a **Duration** for the delay before the next retry, or **null** to stop.

```dart
Duration? myRetry(int retryCount, Object error) {
  if (retryCount >= 5) return null;
  if (error is ProviderException) return null;
  return Duration(milliseconds: 200 * (1 << retryCount));
}
```

### Where to set it

- **Per provider:** Pass `retry: myRetry` when defining the provider (or `@Riverpod(retry: myRetry)` with codegen).
- **Globally:** Pass `retry: myRetry` to **ProviderScope** or **ProviderContainer**.

```dart
// Global
ProviderScope(retry: myRetry, child: MyApp())

// Per provider (manual)
final myProvider = Provider<int>(retry: myRetry, (ref) => 0);
```

### Disabling retry

Return **null** always:

```dart
ProviderScope(retry: (retryCount, error) => null, child: MyApp())
```

### Awaiting async providers with retry

`ref.watch(myProvider.future)` (or equivalent) keeps waiting until either all retries are exhausted or the provider succeeds. So `await ref.watch(myProvider.future)` skips intermediate failures and completes when the provider finally succeeds or gives up.


---
Source attribution: dangdungvn
Original project: https://github.com/dangdungvn/review_system_app/blob/f397d2abe0a8d4c041cd274f0ffc5680d85e7c44/.github/skills/riverpod-retry/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Dave AI.

## Upstream license notice

MIT License

Copyright (c) 2024 Minh Nguyen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Dave AI resource metadata

Creator / publisher: dangdungvn
Original project: https://github.com/dangdungvn/review_system_app/blob/f397d2abe0a8d4c041cd274f0ffc5680d85e7c44/.github/skills/riverpod-retry/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering
Roles: Backend Developer, Full-Stack Developer, Mobile Developer
Specialties: Backend, Mobile
Tools: Riverpod
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: b015b97df89b4b3c07111074d44b71b6ee55faa69b24d6f18dba42f96988edc2
