From 39e398ae025e73dafe632bcfb4f704d66915ab42 Mon Sep 17 00:00:00 2001 From: Luis Pater Date: Fri, 26 Sep 2025 12:10:52 +0800 Subject: [PATCH] feat(watcher): ensure reload callback triggers before auth refresh - Moved `w.reloadCallback(cfg)` invocation to occur before `refreshAuthState()` for proper configuration updates. --- internal/watcher/watcher.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go index 8639a921..e6b820d7 100644 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -553,6 +553,12 @@ func (w *Watcher) reloadClients() { totalNewClients := authFileCount + glAPIKeyCount + claudeAPIKeyCount + codexAPIKeyCount + openAICompatCount + // Ensure consumers observe the new configuration before auth updates dispatch. + if w.reloadCallback != nil { + log.Debugf("triggering server update callback before auth refresh") + w.reloadCallback(cfg) + } + w.refreshAuthState() log.Infof("full client reload complete - old: %d clients, new: %d clients (%d auth files + %d GL API keys + %d Claude API keys + %d Codex keys + %d OpenAI-compat)", @@ -564,12 +570,6 @@ func (w *Watcher) reloadClients() { codexAPIKeyCount, openAICompatCount, ) - - // Trigger the callback to update the server - if w.reloadCallback != nil { - log.Debugf("triggering server update callback") - w.reloadCallback(cfg) - } } // createClientFromFile creates a single client instance from a given token file path.