dotnet / dotnet/aspnetcore

Misleading TaskCanceledException

Open
#4,747 7 comments 0 reactions 0 assignees View on GitHub
affected-very-few area-networking bug feature-kestrel help wanted severity-nice-to-have
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

I have a WebApi endpoint that parses out the Request.Body itself rather than using Model binding due to performance reasons.

During some requests, I was getting a TaskCanceledException from a TextReader that I never gave any CancellationTokens too. After investigation, I found out that any read operations on the Request.Body after the Request was aborted will throw TaskCanceledExceptions. The stack trace at the time didn't list any Kestrel level code so I spent a lot of time trying to find out how a Stream can possibly cancel a token I never gave it.

This is a bit misleading and should probably change I think.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.