microsoft / durabletask-dotnet

Out-of-process .NET SDK for the Durable Task Framework
MIT License
105 stars 31 forks source link

Durable Function - dotnet-isolated - Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="Exception was thrown by handler.") #248

Open gui28347 opened 8 months ago

gui28347 commented 8 months ago

Stack: [2023-11-18T04:13:01.793Z] Function 'MainActivityVM', Invocation id 'b81a7a79-437c-4d76-8ae2-64e48fbbb62e': An exception was thrown by the invocation. [2023-11-18T04:13:01.794Z] Result: Function 'MainActivityVM', Invocation id 'b81a7a79-437c-4d76-8ae2-64e48fbbb62e': An exception was thrown by the invocation. Exception: System.AggregateException: One or more errors occurred. (RunMain Exception: Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="Exception was thrown by handler.") [2023-11-18T04:13:01.795Z] at Microsoft.DurableTask.Client.Grpc.GrpcDurableTaskClient.RaiseEventAsync(String instanceId, String eventName, Object eventPayload, CancellationToken cancellation) [2023-11-18T04:13:01.795Z] at TEST99.SampleFunction.RunMain(FunctionContext context, DurableTaskClient dclient, String vmname, String vmtype) in C:\temp\investigate\AzureAutomation_PersonalDOTNET8\TEST99\SampleFunction.cs:line 82) [2023-11-18T04:13:01.796Z] ---> System.Exception: RunMain Exception: Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="Exception was thrown by handler.") [2023-11-18T04:13:01.797Z] at Microsoft.DurableTask.Client.Grpc.GrpcDurableTaskClient.RaiseEventAsync(String instanceId, String eventName, Object eventPayload, CancellationToken cancellation) [2023-11-18T04:13:01.797Z] at TEST99.SampleFunction.RunMain(FunctionContext context, DurableTaskClient dclient, String vmname, String vmtype) in C:\temp\investigate\AzureAutomation_PersonalDOTNET8\TEST99\SampleFunction.cs:line 82 [2023-11-18T04:13:01.798Z] at TEST99.SampleFunction.RunMain(FunctionContext context, DurableTaskClient dclient, String vmname, String vmtype) in C:\temp\investigate\AzureAutomation_PersonalDOTNET8\TEST99\SampleFunction.cs:line 93 [2023-11-18T04:13:01.799Z] --- End of inner exception stack trace ---

[Function("MainActivityVM")] public static async Task RunMain( [ActivityTrigger] FunctionContext context, [DurableClient] DurableTaskClient dclient, string vmname, string vmtype) { CustomStatusDurableFunction customStatus = new(); try { int i = 0; while (true) { i++; customStatus.progressBar = i; await dclient.RaiseEventAsync(context.InvocationId, "StatusUpdate", customStatus); // line 82 System.Threading.Thread.Sleep(2000); if (i == 100) { break; } } return "OK"; } catch (Exception ex) { throw new Exception($"RunMain Exception: {ex}"); // line 93 } }

jviau commented 7 months ago

Can you provide a minimal repro? What version of the Durable functions extension are you using?

Also, I see in your code you are using an activity to raise an event on another orchestration. This can be performed directly from an orchestration via TaskOrchestrationContext.SendEvent.

gui28347 commented 7 months ago

Microsoft.Azure.Functions.Worker.Extensions.DurableTask Version="1.1.0" Repro code attached: TEST99.zip

jcageman commented 7 months ago

Also have a very simple and probably related example in https://github.com/microsoft/durabletask-dotnet/issues/143#issuecomment-1866278894

jhueppauff commented 5 months ago

I think I am running into the same error as well.

image

Did anyone solved their issues?

Zoe1808 commented 5 months ago

Having the same issue when calling DurableTaskClient#RaiseEventAsync(). @jviau Can you help on this?

jhueppauff commented 4 months ago

I was able to solve it for me. My issue was, that if no Orchestrator is waiting for the eventId we are raising here you are seeing this error await client.RaiseEventAsync(context.InvocationId, "StatusUpdate", customStatus);

Probably, the error message should be updated a bit to reflect this case better.

tinoschnerwitzki commented 2 months ago

Hi, I was having the same exception on durableTaskClient.ScheduleNewOrchestrationInstanceAsync and the comment from jhueppauff pointed me to the solution. Due to another issue, the Orchestration functions did not register during startup. Therefore, if you encounter Grpc exceptions, make sure the orchestration function shows up on startup.

And I agree, the error should says something like "Could not call function xyz". This would have saved me a couple of hour searching in the wrong direction.