docs(retry): clarify abort semantics + remove stale circuit-breaker mention

Two doc-only fixes from PR #393 review (Copilot):

1. **bounded-retry.ts BoundedRetryOptions.signal**
   The previous one-line "if aborted, give up immediately" was technically
   correct from the loop's perspective but misleading about what happens
   to an in-flight operation. Expanded to describe the three observation
   points: sleep wakes immediately, in-flight attempt is forwarded the
   per-attempt signal (only truly immediate if the operation itself
   observes it), and the next loop iteration throws BoundedRetryAbortedError.

2. **retry-utils.ts module-level JSDoc**
   The header still listed "Circuit breaker integration" as a feature.
   The circuitBreaker option was removed in commit b531b46999 and the
   withRetry/retryable/RetryManager helpers in 0f2402da58. Updated the
   header to describe the actual current surface (used for Bad MAC
   recovery on decrypt path) and recommend withBoundedRetry for socket
   operations.

Build clean, 35/35 suites, 809/809 tests pass.

Note: not addressing the suppressed comment about removed APIs being a
breaking change — per maintainer policy this fork has a single consumer,
downstream forks absorb on merge.
This commit is contained in:
Renato Alcara
2026-04-27 00:42:09 -03:00
parent f914ffe272
commit d5796b36b6
2 changed files with 23 additions and 4 deletions
+12 -1
View File
@@ -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
+11 -3
View File
@@ -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
*/