From f97b6874c9b836e8f6313fc2a9cf40cb396e426a Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Tue, 5 May 2026 09:40:03 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(config):=20remove=20racy=20l?= =?UTF-8?q?og.Info=20in=20WatchAndApply=20cancel=20goroutine=20(#48)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gabriel Radureau Co-committed-by: Gabriel Radureau --- pkg/config/config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index e22a937..bb9d2ee 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -730,11 +730,14 @@ func (c *Config) WatchAndApply(ctx context.Context) { // Stop the watcher on context cancel — we set a flag that the // OnConfigChange handler checks, avoiding the race with viper's // internal state that would occur if we called OnConfigChange again. + // We deliberately do NOT log here: viper's internal watcher goroutine + // has no public Stop, so it can outlive ctx, and a zerolog call here + // would race with the next test's LoadConfig → SetupLogging → + // zerolog.SetGlobalLevel under -race (observed 2026-05-05). go func() { <-ctx.Done() c.reloadMu.Lock() c.watcherStopped = true c.reloadMu.Unlock() - log.Info().Msg("Config hot-reload watcher stopped") }() }