feat(watcher): ensure reload callback triggers before auth refresh

- Moved `w.reloadCallback(cfg)` invocation to occur before `refreshAuthState()` for proper configuration updates.
This commit is contained in:
Luis Pater
2025-09-26 12:10:52 +08:00
parent 9bbe64489f
commit 39e398ae02

View File

@@ -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.