← Back to PRs

#7592: fix(slack): prevent unbounded memory growth in channel type cache

by namratabhaumik open 2026-02-03 00:50 View on GitHub →
## Problem Slack channel type cache grows unbounded in large workspaces, causing memory leaks and potential OOM crashes. A workspace with thousands of channels could accumulate gigabytes of memory from cached entries that are never evicted. ## Solution Implement LRU (Least Recently Used) eviction in the Slack channel type cache with a maximum size limit of 1,000 entries. When the cache reaches capacity, the oldest entry is evicted before adding new ones. ## Changes - Add `MAX_SLACK_CHANNEL_CACHE_SIZE` constant (1,000 entries) - Implement `setSlackChannelTypeCache()` helper with LRU eviction logic - Update all 5 cache write sites to use the new helper function ## Impact Prevents memory leaks in long-running gateways serving large Slack workspaces, while maintaining identical cache behavior from the caller's perspective. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds an LRU-style cap (max 1000 entries) to the in-memory Slack channel type cache used by `resolveSlackChannelType()` in `src/infra/outbound/outbound-session.ts`, and updates all cache write sites to route through the new helper. It also adds a changelog entry documenting the fix. The intent is to prevent unbounded memory growth in long-running gateway processes serving large Slack workspaces while keeping the caller-facing behavior the same (still returning cached channel types when available, otherwise falling back to allowlist/config checks and Slack API lookup). <h3>Confidence Score: 3/5</h3> - This PR is close to safe, but has a cache key mismatch that can negate the intended caching/eviction behavior in some configurations. - The LRU cap is straightforward, but the read path uses `${params.accountId ?? "default"}` while writes use `${account.accountId}`, which can cause persistent cache misses and churn; also cache hits do not refresh recency so “LRU” can evict hot entries. No other functional changes were identified. - src/infra/outbound/outbound-session.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs