workflow-core
workflow-core copied to clipboard
How to properly terminate workflow when using ISyncWorkflowRunner.RunWorkflowSync?
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.OnErrorhandler (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?
@danielgerlag can you suggest a workaround?
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 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
Hello! I have same problem. Any options for this case?