diff --git a/src/Utils/bounded-retry.ts b/src/Utils/bounded-retry.ts index 0cd67779..fdc376ca 100644 --- a/src/Utils/bounded-retry.ts +++ b/src/Utils/bounded-retry.ts @@ -129,7 +129,18 @@ export interface BoundedRetryOptions { shouldRetry?: (err: Error, attempt: number) => boolean /** Hook fired before each retry */ onRetry?: (err: Error, attempt: number, delayMs: number) => void - /** AbortSignal — if aborted, give up immediately */ + /** + * AbortSignal — when fired, the loop stops at the next observation point: + * - If the loop is sleeping between retries, the sleep rejects immediately. + * - If an attempt is in flight, the abort is forwarded to the operation + * via the per-attempt signal. The operation must ITSELF observe the + * signal (e.g. `(signal) => fetch({ signal })`) for cancellation to + * be truly immediate; otherwise it cancels at the next per-attempt + * timeout boundary. + * - Either way, on the next loop iteration BoundedRetryAbortedError is + * thrown, so the caller never sees more than one trailing attempt + * after the abort. + */ signal?: AbortSignal /** Optional logger for structured retry/give-up/recovery logs */ logger?: ILogger diff --git a/src/Utils/retry-utils.ts b/src/Utils/retry-utils.ts index cce180d0..2907ea19 100644 --- a/src/Utils/retry-utils.ts +++ b/src/Utils/retry-utils.ts @@ -6,9 +6,17 @@ * - Jitter to avoid thundering herd * - Configurable max attempts * - Customizable retry predicates - * - Circuit breaker integration - * - Event hooks - * - Cancellation support + * - Cancellation support (AbortSignal) + * + * Used by `decode-wa-message.ts` for Bad MAC retry recovery on the decrypt + * path. For socket-operation retries (uploadPreKeys etc.) prefer + * `withBoundedRetry` from `./bounded-retry.ts`, which is empirically + * aligned with WhatsApp Android's per-operation backoff. + * + * NOTE: the previous `circuitBreaker` integration option, the `withRetry` + * decorator, the `retryable` wrapper and the `RetryManager` class were + * removed when the socket-level circuit breaker was retired — see PR #393 + * for the rationale. * * @module Utils/retry-utils */