Failure
Stack strategies in the order they run.
Each call wraps the steps added before it. The timeout bounds one attempt, the retry repeats it, the breaker stops calling a dead service, and the fallback answers.
Read moreconst policy = Tenace.policy({ name: 'users.get' }) .withTimeout('1s') .withRetry({ retries: 3, retryOn: ['TimeoutError'] }) .withCircuitBreaker({ trip: { consecutive: 5 }, openFor: '30s' }) .withFallbackOn(['TimeoutError', 'CircuitOpenError'], () => null)
const user = await policy.execute(({ signal }) => fetchUser(id, { signal }))// user: User | null