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.
This commit is contained in:
SatoshiQaziMuhammed authored and GitHub committed 2026-10-18 14:49:53 +04:00
1 parent a91d455bfb
commit 9f42edc431
1 file changed
+19
@@ -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}`