File tree Expand file tree Collapse file tree
src/HotChocolate/AspNetCore
test/Transport.Http.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ public IAsyncEnumerable<OperationResult> ReadAsResultStreamAsync(CancellationTok
165165
166166 if ( contentType ? . MediaType . EqualsOrdinal ( ContentType . EventStream ) ?? false )
167167 {
168- return new SseReader ( _message ) ;
168+ return new SseReader ( _message , cancellationToken ) ;
169169 }
170170
171171 // The server supports the newer graphql-response+json media type and users are free
Original file line number Diff line number Diff line change 66
77namespace HotChocolate . Transport . Http ;
88
9- internal class SseReader ( HttpResponseMessage message ) : IAsyncEnumerable < OperationResult >
9+ internal class SseReader (
10+ HttpResponseMessage message ,
11+ CancellationToken requestCancellationToken = default ) : IAsyncEnumerable < OperationResult >
1012{
1113 private static readonly StreamPipeReaderOptions s_options = new (
1214 pool : MemoryPool < byte > . Shared ,
@@ -18,8 +20,11 @@ internal class SseReader(HttpResponseMessage message) : IAsyncEnumerable<Operati
1820 public async IAsyncEnumerator < OperationResult > GetAsyncEnumerator (
1921 CancellationToken cancellationToken = default )
2022 {
21- using var cts = CancellationTokenSource . CreateLinkedTokenSource ( cancellationToken ) ;
22- await using var stream = await message . Content . ReadAsStreamAsync ( cts . Token ) ;
23+ using var cts = CancellationTokenSource . CreateLinkedTokenSource (
24+ requestCancellationToken ,
25+ cancellationToken ) ;
26+ await using var stream =
27+ await message . Content . ReadAsStreamAsync ( cts . Token ) . ConfigureAwait ( false ) ;
2328 using var eventBuffer = new PooledArrayWriter ( ) ;
2429 var reader = PipeReader . Create ( stream , s_options ) ;
2530
Original file line number Diff line number Diff line change @@ -713,7 +713,7 @@ mutation CreateReviewForEpisode(
713713 var canceled = false ;
714714 try
715715 {
716- await foreach ( var result in subscriptionResponse . ReadAsResultStreamAsync ( ) . WithCancellation ( cts . Token ) )
716+ await foreach ( var result in subscriptionResponse . ReadAsResultStreamAsync ( cts . Token ) )
717717 {
718718 result . MatchInlineSnapshot (
719719 """
You can’t perform that action at this time.
0 commit comments