Documentacion/API/RetryManager

RetryManager

Recovery standalone con RetryManager.

Recovery standalone (RetryManager)

Si quieres manejar reintentos fuera del boundary:

1import { RetryManager, createExponentialBackoff } from "react-rescuer/recovery";
2
3const mgr = new RetryManager(
4 {
5 maxRetries: 3,
6 retryDelay: (attempt) => Math.min(1000, 200 * 2 ** (attempt - 1)),
7 },
8 createExponentialBackoff(250, 10_000),
9);
10
11const { ok, attempt, delayMs } = mgr.next(
12 "boundary-id",
13 new Error("boom"),
14 context,
15);
COPIAR

Comportamiento

  • next() incrementa el attempt por boundaryId.
  • Si supera maxRetries, llama onMaxRetriesReached y retorna { ok: false }.
  • reset(boundaryId) limpia el contador.
Uso

Esto es util si quieres aplicar politicas de reintento fuera del ErrorBoundary.