handle rate limits gracefully, and add ability to check google server for every request in case they reset rate limits on their end, thereby not relying on local cache alone

This commit is contained in:
Badri Narayanan S
2025-12-21 14:49:57 +05:30
parent f625377bdf
commit 95c08f9d55
3 changed files with 61 additions and 12 deletions

View File

@@ -204,6 +204,21 @@ export class AccountManager {
return cleared;
}
/**
* Clear all rate limits to force a fresh check
* (Optimistic retry strategy)
*/
resetAllRateLimits() {
for (const account of this.#accounts) {
account.isRateLimited = false;
// distinct from "clearing" expired limits, we blindly reset here
// we keep the time? User said "clear isRateLimited value, and rateLimitResetTime"
// So we clear both.
account.rateLimitResetTime = null;
}
console.log('[AccountManager] Reset all rate limits for optimistic retry');
}
/**
* Pick the next available account (round-robin)
*/