1

I am maintaining a Web API project that is used by internal clients only. It is not under heavy load. For the first time I have caught the following exception through my custom exception handling (I use an Attribute to catch anything that is not already caught):

Uncaught Exception System.OperationCanceledException - The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.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.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.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.Controllers.ActionFilterResult.<ExecuteAsync>d__5.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.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()

According to the client logs and the IIS logs, there was > 20 second delay from the time the client called the endpoint in question to the time that IIS logged the request. Most requests have a delay of approx 2-3 seconds because there is a large geographical distance between the client and the server. Not sure if that is relevant, but worth noting that this is definitely an anomaly when looking at all of the other successful requests.

Why would this exception be thrown? How can I reproduce this locally to test it? As mentioned this is the fist time this exception has shown up on my side. I have tried setting a low timeout in a LINQPad script and adding a large delay into my controller but that didn't throw any exception on the ASP.NET side of things.

Micky
  • 11
  • 2
  • This question and answer seems relevant: https://stackoverflow.com/questions/22157596/asp-net-web-api-operationcanceledexception-when-browser-cancels-the-request – meshtron May 06 '19 at 00:25
  • @MikahBarnett thanks - I have read through that one and yes it looks close. What I can't work out from that one is: (1) is this definitely a case of the client closing the connection? (2) will ignoring this exception continue the processing as normal? What I do know is that although I can ignore this particular exception I need to continue on with my controller code because a lot is supposed to happen server-side on this particular request. – Micky May 06 '19 at 00:39

0 Answers0