question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Root cause exception is not exposed in durable function orchestrator

See original GitHub issue

Description

This might be more of an oversight or missing for some other reason, anyways here it is:

Throwing an exception in an activity function causes a DurableTask.Core.Exceptions.TaskFailedException exception. I cannot find a way to extract the root exception from this exception type. Is it supposed to be there? All I get is a message and a type, but the type is an AggregateException.

Also, the documentation here https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-error-handling?tabs=csharp-isolated#errors-in-activity-functions states that it should be a FunctionFailedException exception. When I used inprocess durable functions this exception was thrown and it was possible to extract the root exception. In isolated the documentation is wrong.

Expected behavior

The exception thrown contains the root exception

Actual behavior

The exception thrown containsonly the message of the root exception

App Details

  • Durable Functions extension version (e.g. v1.8.3): “Microsoft.Azure.Functions.Worker.Extensions.DurableTask” Version=“1.0.0” “Microsoft.Azure.WebJobs.Extensions.DurableTask” Version=“2.9.2”
  • Azure Functions runtime version (1.0 or 2.0): 2
  • Programming language used: dotnet

Issue Analytics

  • State:open
  • Created 4 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jviaucommented, Jun 27, 2023

For AggregateException, I believe this is the cause: https://github.com/Azure/azure-functions-dotnet-worker/issues/993.

Will need to see if we can even work around this, given it is an issue with the dotnet worker and not durable.

0reactions
torepaulssoncommented, May 31, 2023

@jviau I believe it has to do with the serialization as you say, and if you remember that it is removed then that is probably it!

@cgillum, DurableTask.Core comes as an inner exception from the aggregate exception. image

[Function(nameof(OrchestrateAsync))]
public async Task OrchestrateAsync([OrchestrationTrigger] TaskOrchestrationContext context)
{
  var replaySafeLogger = context.CreateReplaySafeLogger<Orchestrator>();

  try
  {
    await context.CallActivityAsync(nameof(ThrowExceptionActivityAsync), context.InstanceId);
  }
  catch (Exception e)
  {
    replaySafeLogger.LogError(e, "Orchestrator failed");
    throw;  
  }
}

[Function(nameof(ThrowExceptionActivityAsync))]
public Task ThrowExceptionActivityAsync([ActivityTrigger] string instanceId)
{
  throw new InvalidOperationException("Just a test!");
}

@jviau, in the above code i get an AggregateException but I did not use Task.Result or Task.Wait anywhere here, maybe there is a call to that method inside the code that handles the activities? In the CallActivityAsync maybe?

Packages used

<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.14.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.10.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.0.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.9.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · Azure/azure-functions-durable-extension
Durable Task Framework extension for Azure Functions - Issues ... Root cause exception is not exposed in durable function orchestrator ...
Read more >
Manage instances in Durable Functions - Azure
If the orchestrator function was suspended or terminated, this property includes the reason for the suspension or termination (if any).
Read more >
Handling errors in Durable Functions (Azure Functions)
If an orchestrator function fails with an unhandled exception, the details of the exception are logged and the instance completes with a Failed ......
Read more >
Synchronous call to Durable Orchestrator Function that ...
I am trying to build a durable function in which the orchestrator waits for activity completion and then returns the results af the...
Read more >
Azure Durable Function error handling: Is there a way to ...
This class does not expose properties or methods to obtain the number of retries. Another workaround to help with debugging could be logging ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found