dotnet/aspnetcore

Misleading TaskCanceledException

Open

#4.747 geöffnet am 30. Mai 2018

Auf GitHub ansehen
 (7 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (10.653 Forks)batch import
affected-very-fewarea-networkingbugfeature-kestrelhelp wantedseverity-nice-to-have

Repository-Metriken

Stars
 (37.933 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 16T 9h) (258 gemergte PRs in 30 T)

Beschreibung

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