hermes - 💡(How to fix) Fix Feishu _chat_locks dict grows unbounded — no LRU eviction [2 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

Code Example

# Feishu (unbounded):
self._chat_locks: Dict[str, asyncio.Lock] = {}

# Yuanbao (bounded):
CHAT_DICT_MAX_SIZE = 500  # evicts oldest when full

---

# Add to Feishu adapter
CHAT_LOCK_MAX_SIZE = 500

if len(self._chat_locks) > CHAT_LOCK_MAX_SIZE:
    # Evict oldest unlocked entries
    to_remove = [k for k, v in self._chat_locks.items() if not v.locked()]
    for k in to_remove[:len(self._chat_locks) - CHAT_LOCK_MAX_SIZE]:
        del self._chat_locks[k]
RAW_BUFFERClick to expand / collapse

Bug: Feishu _chat_locks Dict Grows Unbounded

Severity: LOW
File: gateway/platforms/feishu.py
Affected versions: v0.14.0

Problem

The Feishu adapter stores asyncio.Lock objects in a _chat_locks dict keyed by chat_id. Unlike Yuanbao's implementation which has CHAT_DICT_MAX_SIZE for LRU eviction, the Feishu dict grows without bound.

# Feishu (unbounded):
self._chat_locks: Dict[str, asyncio.Lock] = {}

# Yuanbao (bounded):
CHAT_DICT_MAX_SIZE = 500  # evicts oldest when full

Impact

Long-running gateway processes accumulate abandoned Lock objects for one-time or inactive chats. Memory impact is small per entry, but can grow over weeks/months of continuous operation.

Suggested Fix

Apply the same LRU eviction pattern used by Yuanbao:

# Add to Feishu adapter
CHAT_LOCK_MAX_SIZE = 500

if len(self._chat_locks) > CHAT_LOCK_MAX_SIZE:
    # Evict oldest unlocked entries
    to_remove = [k for k, v in self._chat_locks.items() if not v.locked()]
    for k in to_remove[:len(self._chat_locks) - CHAT_LOCK_MAX_SIZE]:
        del self._chat_locks[k]

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix Feishu _chat_locks dict grows unbounded — no LRU eviction [2 pull requests]