Skip to content

HTTP server transport can throw TaskCancelledException when running .NET 10 under certain circumstances #823

@eiriktsarpalis

Description

@eiriktsarpalis

The tests NegativeMaxIdleSessionCount_Throws_ArgumentOutOfRangeException and NegativeNonInfiniteIdleTimeout_Throws_ArgumentOutOfRangeException can throw TaskCanceledException with the following stacktrace:

 System.Threading.Tasks.TaskCanceledException: A task was canceled.
    at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
    at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
    at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
    at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__14_1(IHostedService service, CancellationToken token)
    at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)

I should note that the passed TestContext.Current.CancellationToken is not yet cancelled when that exception gets thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions