From 30080f1acf5ed29e2bca50b9ad0a0e5a34172c8f Mon Sep 17 00:00:00 2001 From: viettranx Date: Tue, 10 Mar 2026 00:16:29 +0700 Subject: [PATCH] fix(channels): pending message compaction never triggering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move count assignment before RAM trim in Record() so MaybeCompact receives pre-trim count (51) that exceeds threshold (50), allowing compaction to fire. Previously count was always ≤ limit after trim. --- internal/channels/history.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/channels/history.go b/internal/channels/history.go index b34cbd77..7047059b 100644 --- a/internal/channels/history.go +++ b/internal/channels/history.go @@ -120,11 +120,11 @@ func (ph *PendingHistory) Record(historyKey string, entry HistoryEntry, limit in ph.mu.Lock() existing := ph.entries[historyKey] existing = append(existing, entry) + count = len(existing) // capture pre-trim count so MaybeCompact sees threshold exceeded if len(existing) > limit { existing = existing[len(existing)-limit:] } ph.entries[historyKey] = existing - count = len(existing) ph.removeFromOrder(historyKey) ph.order = append(ph.order, historyKey) ph.evictOldKeys()