From 2e476dea6323e003377c871df42d3e0b7b797515 Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Wed, 26 Jun 2024 22:16:41 -0400 Subject: [PATCH] fix(oauth): reset rate limit earlier in refresh cycle --- src/client.rs | 1 + src/oauth.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index fb6b56d..1e545a1 100644 --- a/src/client.rs +++ b/src/client.rs @@ -320,6 +320,7 @@ pub async fn json(path: String, quarantine: bool) -> Result { let current_rate_limit = OAUTH_RATELIMIT_REMAINING.load(Ordering::Relaxed); if current_rate_limit < 10 { warn!("Rate limit {current_rate_limit} is low. Spawning force_refresh_token()"); + OAUTH_RATELIMIT_REMAINING.store(99, Ordering::Relaxed); tokio::spawn(force_refresh_token()); } diff --git a/src/oauth.rs b/src/oauth.rs index 61e8044..161310e 100644 --- a/src/oauth.rs +++ b/src/oauth.rs @@ -133,7 +133,6 @@ pub async fn token_daemon() { pub async fn force_refresh_token() { trace!("Rolling over refresh token. Current rate limit: {}", OAUTH_RATELIMIT_REMAINING.load(Ordering::Relaxed)); OAUTH_CLIENT.write().await.refresh().await; - OAUTH_RATELIMIT_REMAINING.store(99, Ordering::Relaxed); } #[derive(Debug, Clone, Default)]