Skip to content

Bug: DiscordEntityCache REST entity Map grows unbounded across bot lifetime #77975

Description

@fede-kamel

Problem

extensions/discord/src/internal/entity-cache.ts caches user:, channel:, guild:, and member: REST fetches in a Map with a 30-second TTL. The TTL is only checked on a same-key re-fetch inside fetchCached. Different keys never trigger any sweep, and there is no max-size cap.

On a long-lived gateway, every distinct entity the bot has ever touched stays retained past its TTL until process restart. Slow, predictable leak proportional to entity cardinality.

Repro is straightforward: drive the unpatched fetchCached path with N unique keys → Map grows to N regardless of TTL.

Tracking PR

Fix in #77952.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions