Skip to main content

Instance configuration

import trybox from "trybox";

const runner = trybox({
  circuitBreaker: {
    failureThreshold: 2,
    resetTimeout: 1000,
    halfOpenRequests: 1,
  },
});

Behavior

  • Opens the circuit after failureThreshold consecutive errors
  • During resetTimeout, calls fail immediately
  • In half-open, limits the number of controlled probes

Per call

import { run } from "trybox";

const r = await run(async () => 1, {
  circuitBreaker: { failureThreshold: 3, resetTimeout: 1500 },
});