You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Call activity which returns Task (async) with custom retry handler using TaskOptions.FromRetryHandler.
The activity throws ApplicationException.
Use LastFailure.IsCausedBy<ApplicationException>() to check whether need to retry.
Expected result: LastFailure.IsCausedBy<ApplicationException>() returns true; Actual result: LastFailure.IsCausedBy<ApplicationException>() returns false;
Sample code
publicclassBackgroundOrchestrationFuncs{[Function(nameof(BackgroundOrchestration))]publicasync Task BackgroundOrchestration([OrchestrationTrigger]TaskOrchestrationContextcontext){varinput= context.GetInput<BackgroundOptions>();TaskOptionsoptions= TaskOptions.FromRetryHandler(context =>{if(!context.LastFailure.IsCausedBy<ApplicationException>())// get false here{returnfalse;}return context.LastAttemptNumber <3;});await context.CallActivityAsync(nameof(RiskyActivity), input, options);}[Function(nameof(RiskyActivity))]publicasync Task RiskyActivity([ActivityTrigger]BackgroundOptionsoptions){await Task.Delay(3000);thrownew ApplicationException("Failed to run!");}}
Details LastFailure contains information about System.AggregateException instead of ApplicationException when activity function is asynchronous.
From the other side if activity function is synchronous then LastFailure contains expected information about ApplicationException.
Repo for reproducing the issue: DurableRetryPlayground
Here is a value of LastFailure during debug session from the repo:
LastFailure {System.AggregateException: One or more errors occurred. (Failed to run!)} Microsoft.DurableTask.TaskFailureDetails
EqualityContract {Name = "TaskFailureDetails" FullName = "Microsoft.DurableTask.TaskFailureDetails"} System.Type {System.RuntimeType}
ErrorMessage "One or more errors occurred. (Failed to run!)" string
ErrorType "System.AggregateException" string
InnerFailure null Microsoft.DurableTask.TaskFailureDetails
StackTrace " at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\r\n at System.Threading.Tasks.Task`1.get_Result()\r\n at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionInvoker`2.<>c.<InvokeAsync>b__6_0(Task`1 t) in D:\\a\\_work\\1\\s\\src\\DotNetWorker.Core\\Invocation\\DefaultFunctionInvoker.cs:line 32\r\n at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()\r\n at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n--- End of stack trace from previous location ---\r\n at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)\r\n--- End of stack trace from previous location ---\r\n at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\\a\\_work\\1\\s\\src\\DotNetWorker.Core\\Invocation\\DefaultFunctionExecutor.cs:line 45\r\n at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\\a\\_work\\1\\s\\src\\DotNetWorker.Core\\OutputBindings\\OutputBindingsMiddleware.cs:line 13\r\n at Microsoft.Azure.Functions.Worker.Extensions.DurableTask.DurableTaskFunctionsMiddleware.Invoke(FunctionContext functionContext, FunctionExecutionDelegate next) in /_/src/Worker.Extensions.DurableTask/DurableTaskFunctionsMiddleware.cs:line 22\r\n at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\\a\\_work\\1\\s\\src\\DotNetWorker.Core\\FunctionsApplication.cs:line 77\r\n at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request) in D:\\a\\_work\\1\\s\\src\\DotNetWorker.Grpc\\Handlers\\InvocationHandler.cs:line 88" string
Could you please clarify whether my expectations are correct?
The text was updated successfully, but these errors were encountered:
Preconditions
Task
(async) with custom retry handler usingTaskOptions.FromRetryHandler
.ApplicationException
.LastFailure.IsCausedBy<ApplicationException>()
to check whether need to retry.Expected result:
LastFailure.IsCausedBy<ApplicationException>()
returnstrue
;Actual result:
LastFailure.IsCausedBy<ApplicationException>()
returnsfalse
;Sample code
Details
LastFailure
contains information aboutSystem.AggregateException
instead ofApplicationException
when activity function is asynchronous.From the other side if activity function is synchronous then
LastFailure
contains expected information aboutApplicationException
.Repo for reproducing the issue: DurableRetryPlayground
Here is a value of
LastFailure
during debug session from the repo:Could you please clarify whether my expectations are correct?
The text was updated successfully, but these errors were encountered: