From 790a4269f778f74d9dcc7756ef7bc2c9052b2978 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Feb 2026 07:54:17 +0000 Subject: [PATCH] fix(daemon): use independent context for fire-and-forget anthropic usage goroutine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sendAnthropicUsageToServer goroutine was reusing the parent's ctx, which gets canceled via defer when fetchRateLimit returns — before the HTTP request can complete. Give the goroutine its own background context with a 10s timeout so it outlives the caller. https://claude.ai/code/session_01Aq7v3ogLxqe5XUM32rVqJY --- daemon/cc_info_timer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/cc_info_timer.go b/daemon/cc_info_timer.go index 1944f22..55de352 100644 --- a/daemon/cc_info_timer.go +++ b/daemon/cc_info_timer.go @@ -433,7 +433,12 @@ func (s *CCInfoTimerService) fetchRateLimit(ctx context.Context) { s.rateLimitCache.mu.Unlock() // Send usage data to server for push notification scheduling (fire-and-forget) - go s.sendAnthropicUsageToServer(ctx, usage) + // Use a separate context so the goroutine isn't canceled when the caller returns. + go func() { + bgCtx, bgCancel := context.WithTimeout(context.Background(), 10*time.Second) + defer bgCancel() + s.sendAnthropicUsageToServer(bgCtx, usage) + }() slog.Debug("Anthropic rate limit updated", slog.Float64("5h", usage.FiveHourUtilization),