Skip to content

[api] Dead code: refresh_meta_cache is gated behind if false, plus unreachable meta cache-priming path #33

Description

@JayDwee

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions