fix(package): [concurrency] stop Take when the source closes (#424)

* fix(package): [concurrency] stop Take when the source closes

* test(package): [concurrency] cover Take with closed and idle source
This commit is contained in:
Lee Sang Gyu authored and GitHub committed 2026-11-09 12:30:17 +08:00
1 parent b4302b2d15
commit c403dd3a2a
2 files changed
+38 -1

No files matched your search

+10 -1
View File
@@ -90,7 +90,16 @@ func (c *Channel[T]) Take(ctx context.Context, valueStream <-chan T, number int)
select {
case <-ctx.Done():
return
case takeStream <- <-valueStream:
case v, ok := <-valueStream:
if !ok {
return
}
select {
case <-ctx.Done():
return
case takeStream <- v:
}
}
}
}()