#7592: fix(slack): prevent unbounded memory growth in channel type cache
Cluster:
Slack Integration Improvements
## 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
#12954: feat(slack): Add channel name resolution with TTL cache
by trevorgordon981 · 2026-02-10
81.7%
#12997: feat(infra): Add query caching layer with TTL and LRU eviction
by trevorgordon981 · 2026-02-10
79.7%
#12414: fix(slack): do not cache API failures in thread_ts resolver
by Yida-Dev · 2026-02-09
77.9%
#8024: fix(slack): resolve channel names via directory for cross-account m...
by emma-digital-assistant · 2026-02-03
77.5%
#23056: fix(slack): exclude archived channels from startup channel resolution
by dbachelder · 2026-02-21
77.3%
#10686: fix(slack): use thread-level sessions for channels to prevent conte...
by pablohrcarvalho · 2026-02-06
76.2%
#10280: fix(infra): add max size limit to Tailscale whois cache to prevent ...
by programming-pupil · 2026-02-06
76.0%
#5312: fix(slack): skip users.list API call when all user entries are IDs
by gunpyo-park-musinsa · 2026-01-31
75.8%
#22433: Slack: fix thread context loss after session reset
by stgarrity · 2026-02-21
75.8%
#13882: feat: Enhance session checkpoint system with better types and valid...
by trevorgordon981 · 2026-02-11
75.7%