From 0700c44d5924b846aad68b0d18335a6ffef68d24 Mon Sep 17 00:00:00 2001 From: Renato Alcara Date: Mon, 27 Apr 2026 00:07:05 -0300 Subject: [PATCH] chore(socket): remove dead retryCount param from uploadPreKeys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #393 review (low-confidence comment): the retryCount parameter and its `=== 0` guard were leftovers from the previous manual recursive backoff. Now that bounded-retry handles retries internally, the recursion is gone and retryCount is always 0. Drop the parameter, remove the guard (the check applies always), and simplify the log statement (no more "retryCount" in the structured data — bounded-retry's own logger logs attempt counts). Build clean, 35/35 suites, 809/809 tests pass. --- src/Socket/socket.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index fda5483f..8cc5e565 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -612,14 +612,14 @@ export const makeSocket = (config: SocketConfig) => { let lastUploadTime = 0 /** generates and uploads a set of pre-keys to the server */ - const uploadPreKeys = async (count = MIN_PREKEY_COUNT, retryCount = 0) => { - // Check minimum interval (except for retries) - if (retryCount === 0) { - const timeSinceLastUpload = Date.now() - lastUploadTime - if (timeSinceLastUpload < MIN_UPLOAD_INTERVAL) { - logger.debug(`Skipping upload, only ${timeSinceLastUpload}ms since last upload`) - return - } + const uploadPreKeys = async (count = MIN_PREKEY_COUNT) => { + // Check minimum interval. (Previously this was guarded by `retryCount === 0` + // because the function recursed on retry; with bounded-retry handling + // retries internally there is no recursion and the guard is implicit.) + const timeSinceLastUpload = Date.now() - lastUploadTime + if (timeSinceLastUpload < MIN_UPLOAD_INTERVAL) { + logger.debug(`Skipping upload, only ${timeSinceLastUpload}ms since last upload`) + return } // Prevent multiple concurrent uploads — if one is already running, wait for it and return: @@ -631,7 +631,7 @@ export const makeSocket = (config: SocketConfig) => { } const uploadLogic = async () => { - logger.info({ count, retryCount }, 'uploading pre-keys') + logger.info({ count }, 'uploading pre-keys') // Generate and save pre-keys atomically (prevents ID collisions on retry) const node = await keys.transaction(async () => {