问题描述
最近,我在我的后端API的应用程序添加错误日志记录每UnobservedTaskException。
其原因是,一些API调用执行这些完成后,我返回的结果额外的任务,这就是为什么我不能行动有跟踪错误(网络API调用)的水平。
Recently I have added error logging for every UnobservedTaskException at my backend API app.The reason is that some API call executes additional tasks which are finished AFTER I return the result, that is why I couldn't track errors there on action (web api calls) level.
现在我得到很多的操作被取消异常和不知道该怎么办。我甚至不知道这异常是由API调用执行我的任务造成的。
Now I'm getting lots of "The operation was canceled" exceptions and not sure what to do with it. I even not sure that this exception is caused by my tasks executed by API call.
下面是堆栈:
System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowIfCancellationRequested()
at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.WebHost.HttpControllerHandler.<CopyResponseAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.WebHost.HttpControllerHandler.<ProcessRequestAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar)
at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)
任何想法如何调试呢?
Any ideas how to debug it?
推荐答案
任务取消例外,从任务通常来自一个被中止的请求。我们正在追踪将其固定在5.2而这些都不会在异常记录器显示的错误。所以,通常你可以放心地忽略这些。
Task cancel exception comes typically from tasks from an aborted request. We are tracking a bug that will be fixed in 5.2 where these are not going to show up in the exception logger. So typically you can safely ignore these.
您可以拿起每晚构建的https://www.myget.org/gallery/aspnetwebstacknightly验证此解决您的问题。
You can pick up the nightly builds on https://www.myget.org/gallery/aspnetwebstacknightly to verify this fixes your issue.
下面是错误的链接:<一个href=\"http://aspnetwebstack.$c$cplex.com/workitem/1797\">http://aspnetwebstack.$c$cplex.com/workitem/1797
这篇关于这次行动是在TaskScheduler.UnobservedTaskException中的WebAPI取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!