Severity
Low — dead code / confusing intent
Location
api/src/meta/guilds.rs:34-39 and refresh_meta_cache at api/src/meta/guilds.rs:114-137
Problem
pub fn setup(discord_bot: Arc<Client>) {
info!("Spawning meta cache refresh task"); // logs even though nothing spawns
if false {
tokio::spawn(refresh_meta_cache(discord_bot));
}
}
- The
if false guard means refresh_meta_cache never runs, yet the "Spawning meta cache refresh task" info line still prints on every cold start (also duplicated in meta/mod.rs:19), implying a background task exists when it doesn't.
refresh_meta_cache references get_current_user_guilds_prime_cache / get_guild_prime_cache (imported at meta/guilds.rs:2-5) — cache-priming variants that add complexity solely for this disabled path.
- The sleep math is also suspect:
time.sub(Instant::now()) computes a negative-ish Duration (it's start - now, i.e. already elapsed, saturating to ~0) then adds 50s — the debug log claiming to wait computes it in the opposite direction. This would misbehave if ever enabled.
In a Lambda execution model a long-lived loop { sleep } background task generally can't run reliably between invocations anyway, so this may be the wrong pattern entirely.
Suggested resolution
Either delete setup/refresh_meta_cache and the *_prime_cache helpers if caching is handled by the #[cached] TTLs already on the get_* functions, or, if a warm cache is genuinely needed, move it to a scheduled invocation (EventBridge) rather than an in-process loop and remove the if false. At minimum, drop the misleading log line until the task actually spawns.
Severity
Low — dead code / confusing intent
Location
api/src/meta/guilds.rs:34-39andrefresh_meta_cacheatapi/src/meta/guilds.rs:114-137Problem
if falseguard meansrefresh_meta_cachenever runs, yet the "Spawning meta cache refresh task" info line still prints on every cold start (also duplicated inmeta/mod.rs:19), implying a background task exists when it doesn't.refresh_meta_cachereferencesget_current_user_guilds_prime_cache/get_guild_prime_cache(imported atmeta/guilds.rs:2-5) — cache-priming variants that add complexity solely for this disabled path.time.sub(Instant::now())computes a negative-ishDuration(it'sstart - now, i.e. already elapsed, saturating to ~0) then adds 50s — the debug log claiming to wait computes it in the opposite direction. This would misbehave if ever enabled.In a Lambda execution model a long-lived
loop { sleep }background task generally can't run reliably between invocations anyway, so this may be the wrong pattern entirely.Suggested resolution
Either delete
setup/refresh_meta_cacheand the*_prime_cachehelpers if caching is handled by the#[cached]TTLs already on theget_*functions, or, if a warm cache is genuinely needed, move it to a scheduled invocation (EventBridge) rather than an in-process loop and remove theif false. At minimum, drop the misleading log line until the task actually spawns.