nestjs-backend-common
    Preparing search index...

    Function retry

    • Type Parameters

      • TResult

      Parameters

      Returns RetryResult<TResult>

      It tries to call the given synchronous func with the given options. Unlike retryAsync, this handles functions that throw synchronous errors (e.g., JSON.parse('invalid')).

      This function is fully synchronous and does not support delays between retries. If you need delay/backoff support, use retryAsync instead. The returned value is analogous to the error handling mechanism in Golang.

      const [error, result] = retry(
      () => JSON.parse('{"valid": true}'),
      { retry: 3 },
      );
      if (error) {
      throw error;
      }
      console.log(result);