Recommended patterns for retries, cancellation, and observability
import trybox from "trybox"; export const runner = trybox({ ignoreAbort: true });
mapError
const runner = trybox({ mapError: (e) => ({ ...e, message: e.message }) });
await runner.run(() => fetch("/api"), { retries: 3, shouldRetry: (attempt, e, ctx) => e.code !== "ABORTED" && ctx.elapsedTime < 5000, });
await runner.run(() => fetch("/api"), { retryDelay: 300, jitter: 0.5, backoffStrategy: "exponential" });