annotations-design-patterns
    Preparing search index...

    Function Retry

    • Reintenta un método asíncrono cuando lanza o rechaza, hasta agotar los intentos. Si todos fallan, propaga el último error. Con backoffFactor la espera crece exponencialmente entre reintentos.

      Parameters

      Returns <This extends object, Args extends unknown[], Return>(
          target: (this: This, ...args: Args) => Promise<Return>,
          context: ClassMethodDecoratorContext<
              This,
              (this: This, ...args: Args) => Promise<Return>,
          >,
      ) => (this: This, ...args: Args) => Promise<Return>

      class Api {
      @Retry({ attempts: 4, delayMs: 200, backoffFactor: 2 }) // 200, 400, 800 ms
      async fetchUser(id: string): Promise<User> { ... }
      }