Closed orthoplex64 closed 4 years ago
Hi Christopher, thanks for reaching out. Which version of AspNetCore are you using? Do you have a repro to share? Thanks
I'm using ASP.NET Core 2.2. Sorry, I don't have a repository, but I'll put one together and get back to you.
That would really help.
The middleware get the headers from the HttpContext
and put then in a AsyncLocal
so I can't think of a reason when this could fail.
Are you consuming an HttpClient
configured with the header propagation also from outside of the request pipeline (e.g. from a IHostedService
)?
Here's a repository with a demo project: https://github.com/orthoplex64/dotnet-demos The HttpClient is being consumed within the request pipeline, in a controller action
I submitted this issue to the ASP.NET Core project as well, and it was identified with a known problem with Kestrel: https://github.com/aspnet/AspNetCore/issues/15384
Thanks! this really helps to understand the problem! I'll work on a solution
When using
app.UseHeaderPropagation();
as the first middleware in the pipeline and sending many simultaneous requests, I've observed incorrect headers being propagated sometimes.When inserting any async middleware before header propagation (e.g.
app.Use(async (context, next) => await next.Invoke());
), all propagated headers are correct.