From 7c4e57cf18153e0852bc0bb033ee6f7ebf9c98ec Mon Sep 17 00:00:00 2001 From: dj-oyu <68707227+dj-oyu@users.noreply.github.com> Date: Tue, 24 Feb 2026 16:06:04 +0900 Subject: [PATCH] fix: data race in WeComBot processedMsgs map access len(c.processedMsgs) was read outside the lock while another goroutine could be writing to the map. Move the cleanup check inside the existing critical section. Co-Authored-By: Claude Opus 4.6 --- pkg/channels/wecom.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/channels/wecom.go b/pkg/channels/wecom.go index f8daf89de..af3f228ca 100644 --- a/pkg/channels/wecom.go +++ b/pkg/channels/wecom.go @@ -339,14 +339,11 @@ func (c *WeComBotChannel) processMessage(ctx context.Context, msg WeComBotMessag return } c.processedMsgs[msgID] = true - c.msgMu.Unlock() - // Clean up old messages periodically (keep last 1000) if len(c.processedMsgs) > 1000 { - c.msgMu.Lock() c.processedMsgs = make(map[string]bool) - c.msgMu.Unlock() } + c.msgMu.Unlock() senderID := msg.From.UserID