Skip to content

Commit 77e8460

Browse files
Address code review feedback
- Remove unused System.Text.Json import from test - Use consistent attribute style in test - Add clarifying comment explaining the buffer completion check Co-authored-by: electricessence <5899455+electricessence@users.noreply.github.com>
1 parent a0cfda5 commit 77e8460

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Open.ChannelExtensions.Tests/HangReproTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Text.Json;
1+
using System.Runtime.CompilerServices;
22

33
namespace Open.ChannelExtensions.Tests;
44

@@ -42,7 +42,7 @@ await GetSource()
4242
Assert.All(counts, count => Assert.True(count >= 40, $"Count was {count}, expected at least 40"));
4343
}
4444

45-
private static async IAsyncEnumerable<int> GetSource([System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken = default)
45+
private static async IAsyncEnumerable<int> GetSource([EnumeratorCancellation] CancellationToken cancellationToken = default)
4646
{
4747
foreach (var value in Enumerable.Range(0, Random.Shared.Next(80, 120)))
4848
{

Open.ChannelExtensions/Readers/BatchingChannelReader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ protected override async ValueTask<bool> WaitToReadAsyncCore(
256256
// Await the source task to check if it completed and get its result
257257
// This prevents a tight loop when the source is closed
258258
await sTask.ConfigureAwait(false);
259+
// Check if buffer completed while we were waiting (e.g., timeout forced a batch)
260+
// If so, return immediately without trying to pipe more items
259261
if (b.IsCompleted)
260262
return await b.ConfigureAwait(false);
261263

0 commit comments

Comments
 (0)