Skip to content

Commit 360b80e

Browse files
authored
Consume ValueTask with GetAwaiter().GetResult() (#29710)
* Update Http2Stream.cs * Update ComponentState.cs
1 parent e737b6e commit 360b80e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Components/Components/src/Rendering/ComponentState.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ public Task DisposeInBatchAsync(RenderBatchBuilder batchBuilder)
236236
var result = ((IAsyncDisposable)Component).DisposeAsync();
237237
if (result.IsCompletedSuccessfully)
238238
{
239+
// If it's a IValueTaskSource backed ValueTask,
240+
// inform it its result has been read so it can reset
241+
result.GetAwaiter().GetResult();
239242
return Task.CompletedTask;
240243
}
241244
else

src/Servers/Kestrel/Core/src/Internal/Http2/Http2Stream.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ public Task OnDataAsync(Http2Frame dataFrame, in ReadOnlySequence<byte> payload)
450450
// It shouldn't be possible for the RequestBodyPipe to fill up an return an incomplete task if
451451
// _inputFlowControl.Advance() didn't throw.
452452
Debug.Assert(flushTask.IsCompletedSuccessfully);
453+
454+
// If it's a IValueTaskSource backed ValueTask,
455+
// inform it its result has been read so it can reset
456+
flushTask.GetAwaiter().GetResult();
453457
}
454458
}
455459
}

0 commit comments

Comments
 (0)