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.