From 5bebfce972b0ba3fda126b8ec0fc4c0cc4586065 Mon Sep 17 00:00:00 2001 From: dj-oyu <68707227+dj-oyu@users.noreply.github.com> Date: Tue, 24 Feb 2026 17:18:46 +0900 Subject: [PATCH] fix: context leak in TestChatStream_EarlyCancel Add defer cancel() so the context is always cancelled, even when the loop exits early due to an error before reaching 5 events. Co-Authored-By: Claude Opus 4.6 --- pkg/providers/openai_compat/provider_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/providers/openai_compat/provider_test.go b/pkg/providers/openai_compat/provider_test.go index 2d4badc04..ffb8cb761 100644 --- a/pkg/providers/openai_compat/provider_test.go +++ b/pkg/providers/openai_compat/provider_test.go @@ -637,6 +637,7 @@ func TestChatStream_EarlyCancel(t *testing.T) { p := NewProviderWithOptions("key", server.URL, "", Options{Stream: true}) ctx, cancel := context.WithCancel(context.Background()) + defer cancel() ch, err := p.ChatStream(ctx, []Message{{Role: "user", Content: "hi"}}, nil, "test", nil) if err != nil { t.Fatalf("ChatStream() error = %v", err)