aspnetcore: Unexpected exception in TimingPipeFlusher.TimeFlushAsync when using HttpProtocols.Http1AndHttp2

I’m getting a couple dozen “Unexpected exception in TimingPipeFlusher.TimeFlushAsync” exceptions in my logs every day. This happens only when HTTP2 support is enabled in Kestrel.

System.InvalidOperationException: Can't GetResult unless awaiter is completed.
   at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_GetResultNotCompleted()
   at System.IO.Pipelines.Pipe.GetFlushAsyncResult()
   at System.IO.Pipelines.Pipe.DefaultPipeWriter.GetResult(Int16 token)
   at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TimingPipeFlusher.TimeFlushAsync(MinDataRate minRate, Int64 count, IHttpOutputAborter outputAborter, CancellationToken cancellationToken)

I can’t seem to trigger it myself. The exceptions occur on a production server.

The app is running in Kubernetes from the mcr.microsoft.com/dotnet/core/aspnet:2.2.3-alpine image.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 29 (23 by maintainers)

Most upvoted comments

A wrapper would be just be more overhead, state machines, etc…

Honestly we don’t see many people switch between Http.Sys and Kestrel. They usually switch between IIS and Kestrel. If they’re using Http.Sys it’s for a specific feature not available elsewhere.

As expected forcing HttpProtocols.Http2 results in the same exception as HttpProtocols.Http1AndHttp2. Also not related to Alpine, same happens with regular image. I will try to enable verbose logging and see if I can find out more.