From 9f42edc43185ec214a584062f71fcbc8227883f0 Mon Sep 17 00:00:00 2001 From: SatoshiQaziMuhammed Date: Sun, 18 Oct 2026 14:49:53 +0400 Subject: [PATCH] check-deposits: log TronGrid's 429 reason and stop the run's TRC20 checks at it (#34) After the pacing fix, 429 still came back in about a third of the runs: from around the 17th user on, every request was refused, retries included (measured 2026-10-18 over 404 runs). The body of that answer says which limit was hit and for how long, and it was never logged. The first 429 of a run now logs it, and the users after it are skipped with one line saying how many, instead of each being sent into the same limit. --- supabase/functions/check-deposits/index.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/supabase/functions/check-deposits/index.ts b/supabase/functions/check-deposits/index.ts index 23bbdad..90f5f78 100644 --- a/supabase/functions/check-deposits/index.ts +++ b/supabase/functions/check-deposits/index.ts @@ -302,7 +302,21 @@ async function checkTrc20Deposits( // skipped every later user (measured on two consecutive runs, 2026-10-17). const CONCURRENCY = 8; const BATCH_INTERVAL_MS = 1100; + // Once TronGrid answers 429 inside a run, every later request in that run + // has been refused too (measured 2026-10-18: from about the 17th user on, + // in a third of the runs), so the rest of the run is skipped rather than + // sent into the limit. The first 429's body is logged: it says which limit + // was hit and for how long. + let limitedAt: number | null = null; for (let i = 0; i < users.length; i += CONCURRENCY) { + if (limitedAt !== null) { + const skipped = users.length - i; + console.error( + `TronGrid 429 at deposit index ${limitedAt}: ${skipped} later users not checked this run` + ); + result.errors.push(`TronGrid 429: ${skipped} users not checked this run`); + break; + } const batch = users.slice(i, i + CONCURRENCY); const batchStart = Date.now(); await Promise.all( @@ -316,6 +330,11 @@ async function checkTrc20Deposits( ); if (!response.ok) { + if (response.status === 429 && limitedAt === null) { + limitedAt = user.deposit_index; + const body = (await response.text()).slice(0, 300); + console.error(`TronGrid 429 body: ${body}`); + } console.error(`TronGrid ${response.status} for deposit index ${user.deposit_index}`); result.errors.push( `TronGrid ${response.status} for deposit index ${user.deposit_index}`