• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

KusionStack / karpor / 39579317773
65%

Build:
DEFAULT BRANCH: main
Ran 21 Oct 2026 09:45AM UTC
Jobs 1
Files 68
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

21 Oct 2026 09:44AM UTC coverage: 65.213% (+1.2%) from 64.035%
39579317773

push

github

web-flow
fix(ai): stop the stream goroutine when the context is cancelled (#866)

## What type of PR is this?

/kind bug

## What this PR does / why we need it:

`GenerateStream` of the OpenAI, Azure OpenAI and DeepSeek clients
(`pkg/infra/ai`) starts a goroutine that sends every chunk, and the
final `ERROR: ...` message, to a buffered channel (size 100) without
looking at `ctx`. If the consumer stops reading and cancels the context
(for example the HTTP client disconnected), the goroutine blocks forever
on the full channel and keeps the upstream HTTP response open.

This wraps the sends in a `select` on `ctx.Done()`, the same way the
Hugging Face client already does.

## Tests

New `pkg/infra/ai/stream_cancel_test.go`: a server streams 300 chunks
(more than the buffer), the consumer reads nothing and cancels the
context, and the test checks that the `GenerateStream` goroutine exits.
It runs for the three clients, fails on `main` for all three and passes
with the change. `gofmt`, `go vet` and `go test ./pkg/infra/ai/` are
clean (golang:1.26 container).

## Special notes for your reviewer:

This change was made with Claude Code.

Co-authored-by: elliotxx <951376975@qq.com>

12 of 21 new or added lines in 3 files covered. (57.14%)

5 existing lines in 4 files now uncovered.

4501 of 6902 relevant lines covered (65.21%)

0.72 hits per line

Uncovered Changes

Lines Coverage ∆ File
3
56.58
56.58% pkg/infra/ai/azureopenai.go
3
82.72
-1.7% pkg/infra/ai/deepseek.go
3
58.97
58.97% pkg/infra/ai/openai.go

Coverage Regressions

Lines Coverage ∆ File
2
57.4
-0.9% pkg/syncer/single_cluster_sync_manager.go
1
56.58
56.58% pkg/infra/ai/azureopenai.go
1
82.72
-1.7% pkg/infra/ai/deepseek.go
1
58.97
58.97% pkg/infra/ai/openai.go
Jobs
ID Job ID Ran Files Coverage
1 39579317773.1 21 Oct 2026 09:45AM UTC 68
65.21
GitHub Action Run
Source Files on build 39579317773
  • Tree
  • List 68
  • Changed 4
  • Source Changed 0
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 87a98a7c on github
  • Prev Build on main (#39578577111)
  • Next Build on main (#39894634967)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc