workflow-core icon indicating copy to clipboard operation
workflow-core copied to clipboard

How to properly terminate workflow when using ISyncWorkflowRunner.RunWorkflowSync?

Open chester89 opened this issue 5 years ago • 4 comments
trafficstars

Hello. I'm running workflows from inside ASP.NET Core app - launching it via ISyncWorkflowRunner.RunWorkflowSync and noticed some strange behaviour:

  • I assumed that builder.StartWith<Step1>().OnError(WorkflowErrorHandling.Terminate) will end workflow execution and throw an error you had inside a step. however, next steps are still running
  • I tried providing workflowHost.OnError handler (throwing exception from there) - that didn't stop workflow execution either when one of my steps failed

The reason I'm using ISyncWorkflowRunner is because I need to send workflow results back to the client. What I'd like is a way to say (perhaps for all my workflows) - "if there's an exception inside my step, please don't run the workflow further, let the app know". What is the proper way to achieve such behaviour?

chester89 avatar Sep 29 '20 12:09 chester89

@danielgerlag can you suggest a workaround?

chester89 avatar Oct 07 '20 10:10 chester89

It should terminate the workflow, but I don't think the unhandled exception would bubble up to the caller that started the workflow, you'd need to inspect the state of the workflow once the method returned, to determine if it was successful.

danielgerlag avatar Oct 17 '20 16:10 danielgerlag

@danielgerlag how can I determine the reason (exception) why the workflow failed? I only found WorkflowStatus on WorkflowInstance class - this is telling the end result (e.g. fail), not the reason

chester89 avatar Oct 19 '20 06:10 chester89

Hello! I have same problem. Any options for this case?

gineshdoruk avatar Aug 13 '24 07:08 gineshdoruk