From 50226ae389b6058a027517ccbfe447a703b33ee1 Mon Sep 17 00:00:00 2001 From: Renato Alcara Date: Thu, 30 Apr 2026 10:34:04 -0300 Subject: [PATCH] fix(decrypt): correct 1-based attempt check for unknown-error retry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex P2 review caught: `retry()` in retry-utils.ts iterates with `for (let attempt = 1; ...)`, so the `attempt` passed to `shouldRetry` on the first failure is 1, not 0. The previous `attempt < 1` was therefore always false → no retry on unknown errors, contradicting the inline policy comment ("one retry in case it was a transient blip"). Use `attempt < 2` so the SECOND pass happens (initial + 1 retry = 2 total attempts, which matches `maxAttempts: 2`) and the third pass is refused. The session-record / corrupted-session branches above already return false unconditionally and are not affected. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/Utils/decode-wa-message.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Utils/decode-wa-message.ts b/src/Utils/decode-wa-message.ts index d61c8b3c..751fe632 100644 --- a/src/Utils/decode-wa-message.ts +++ b/src/Utils/decode-wa-message.ts @@ -119,7 +119,9 @@ export const DECRYPTION_RETRY_OPTIONS: RetryOptions = { } // Unknown errors: one retry in case it was a transient blip. - return attempt < 1 + // `attempt` is 1-based (retry-utils starts the loop at 1), so `attempt < 2` + // allows the second pass and returns false on the third. + return attempt < 2 } }