From b3d64d47b3c08c8e6dc125a98b9d91bcbd74290f Mon Sep 17 00:00:00 2001 From: biantaishabi2 <130463181+biantaishabi2@users.noreply.github.com> Date: Mon, 5 Jan 2026 03:14:36 +0800 Subject: [PATCH] fix: prevent event storm when gitRefsPath is empty (#883) When gitRefsPath is empty (not in a git repo), strings.HasPrefix(path, "") always returns true, causing every file write in .beads/ directory (including daemon.log) to trigger debouncer and create an event storm. This fix adds a check to ensure gitRefsPath is not empty before the HasPrefix comparison. Fixes the issue where daemon.log grows rapidly (17MB+) due to the self-triggering loop: write log -> detect change -> write log -> ... Co-authored-by: Test User --- cmd/bd/daemon_watcher.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/bd/daemon_watcher.go b/cmd/bd/daemon_watcher.go index 848d0414..c42b2dae 100644 --- a/cmd/bd/daemon_watcher.go +++ b/cmd/bd/daemon_watcher.go @@ -210,7 +210,8 @@ func (fw *FileWatcher) Start(ctx context.Context, log daemonLogger) { } // Handle git ref changes (only events under gitRefsPath) - if event.Op&fsnotify.Write != 0 && strings.HasPrefix(event.Name, fw.gitRefsPath) { + // Fix: check gitRefsPath is not empty, otherwise HasPrefix("any", "") is always true + if fw.gitRefsPath != "" && event.Op&fsnotify.Write != 0 && strings.HasPrefix(event.Name, fw.gitRefsPath) { if fw.shouldLogGitRefChange() { log.log("Git ref change detected: %s", event.Name) }