Closed Meowzz95 closed 4 years ago
Compare between dotnet run and from visual studio
Finish loading fast:
Finish loading slow:
Which servers? On Mac you must be using Kestrel and http/1.1. In Windows the default is IIS In-Process.
https://github.com/dotnet/aspnetcore/issues/17268 just improved some of this behavior for IIS In-Process in 5.0.0 rc1. You should be able to try a nightly build soon.
As for kestrel, this behavior makes some sense if the two requests are sent on the same connection back to back. The first request is processed, the response sent, and then OnCompleted gets delayed before it continues processing the next request. If you look at the server logs, both requests should have the same connection ID. In kestrel each connection is effectively a single threaded loop and it reuses most of the structures for the next request, so it needs you to be done with them before continuing.
Note HTTP/2 is mostly not affected by these issues because it's designed to multiplex requests. HTTP/2 is enabled by default for https on Windows, but it's not supported on Mac.
Thanks for the explanation, it now makes sense for the different behaviors.
However, according to the documentation
Adds a delegate to be invoked after the response has finished being sent to the client.
The delegate should be invoked only after the response finishes sending to the client. So why the page or the fav icon is delayed 7s in this case?
Because on kestrel that 7s of delay happens at the end of the prior request, before the favicon request even begins processing.
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.
Describe the bug
The above code should register a handler for OnCompleted event and does not block. This works partially correctly but I found the fav icon is loaded in 6.96s every time I try. To me this looks like somehow the sleep is delaying the load of fav icon.
One of my friends who is on Windows env, reports that the same code, giving different behaviour, which blocks the page for 7s instead of blocking the fav icon, he will follow up in this thread.
To Reproduce
The complete min reproduce can be found here: https://github.com/Meowzz95/TestResponseOnCompleted
Further technical details
ASP.NET Core version 3.1 Include the output of
dotnet --info
IDE: JB Rider JetBrains Rider 2020.2