Skip to content

@Retry

Retry async methods with configurable attempts, delay, backoff, and per-attempt timeout.

KindRuntime
Backendslegacy, stage3
Requires generateNo

Example

ts
import { Retry } from 'lombok-typescript/legacy';

class ApiClient {
  @Retry({ attempts: 3, delay: 500, backoff: 'exponential' })
  async fetchUser(id: string) {
    return await fetch(`/users/${id}`).then((r) => r.json());
  }
}

Options

OptionDefaultDescription
attempts3Total tries including the first call
delay1000Base delay in ms between retries
backoff'fixed''fixed', 'linear', 'exponential'
retryIfalwaysPredicate to decide whether to retry
timeoutPer-attempt timeout in ms

Composition

Stack with @Trace for observability. Place @Trace above @Retry in source order so tracing wraps the retry wrapper.

Released under the MIT License.