Compare commits
1 Commits
fix/config
...
fix/race-i
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d95259667 |
@@ -730,11 +730,14 @@ func (c *Config) WatchAndApply(ctx context.Context) {
|
|||||||
// Stop the watcher on context cancel — we set a flag that the
|
// Stop the watcher on context cancel — we set a flag that the
|
||||||
// OnConfigChange handler checks, avoiding the race with viper's
|
// OnConfigChange handler checks, avoiding the race with viper's
|
||||||
// internal state that would occur if we called OnConfigChange again.
|
// 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() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
c.reloadMu.Lock()
|
c.reloadMu.Lock()
|
||||||
c.watcherStopped = true
|
c.watcherStopped = true
|
||||||
c.reloadMu.Unlock()
|
c.reloadMu.Unlock()
|
||||||
log.Info().Msg("Config hot-reload watcher stopped")
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user