Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headers mangled without previous async middleware #7

Closed
orthoplex64 opened this issue Oct 14, 2019 · 7 comments · Fixed by #9
Closed

Headers mangled without previous async middleware #7

orthoplex64 opened this issue Oct 14, 2019 · 7 comments · Fixed by #9

Comments

@orthoplex64
Copy link

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.

@alefranz
Copy link
Owner

alefranz commented Oct 14, 2019

Hi Christopher,
thanks for reaching out.
Which version of AspNetCore are you using?
Do you have a repro to share?
Thanks

@orthoplex64
Copy link
Author

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.

@alefranz
Copy link
Owner

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)?

@orthoplex64
Copy link
Author

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

@orthoplex64
Copy link
Author

I submitted this issue to the ASP.NET Core project as well, and it was identified with a known problem with Kestrel: dotnet/aspnetcore#15384

@alefranz
Copy link
Owner

Thanks! this really helps to understand the problem!
I'll work on a solution

@alefranz
Copy link
Owner

I've released 3.0.2 which address the issue.
Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants