Zap Studio

FixedDelay

Retry policy with a constant delay between attempts.

FixedDelay retries using a constant interval until max attempts is reached.

Import

import { FixedDelay } from "@zap-studio/retry/fixed-delay";

Configuration

const policy = new FixedDelay({
  maxAttempts: 4,
  delayMs: 300,
});

Behavior

  • Every retry uses the same delayMs
  • Stops when attempt >= maxAttempts
  • Returns a terminal decision with reason: "max-attempts-reached"

When to Use

Use FixedDelay when:

  • your backend has predictable recovery windows
  • you want straightforward retry timing
  • you need easy-to-debug behavior in tests

Example

const policy = new FixedDelay({
  maxAttempts: 3,
  delayMs: 250,
});

const value = await policy.run(async () => {
  return await readFromCacheOrApi();
});
Edit on GitHub

Last updated on

On this page