Skip to content

Unexpected behaviour for Response.OnCompleted #25122

@Meowzz95

Description

@Meowzz95

Describe the bug

Response.OnCompleted(async () =>
                {
                    _logger.LogInformation($"In complete callback, going to sleep");
                    await Task.Run(() => Thread.Sleep(7000));
                    _logger.LogInformation($"sleep done");
                });

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.
image

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

.NET Core SDK (reflecting any global.json):
 Version:   3.1.201
 Commit:    b1768b4ae7

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.1.201/

Host (useful for support):
  Version: 3.1.3
  Commit:  4a9f85e9f8

.NET Core SDKs installed:
  3.1.201 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

IDE: JB Rider JetBrains Rider 2020.2

Build #RD-202.6397.244, built on August 11, 2020

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions