We have a workflow that uses session to run all activities on one worker, one of these activities creates a temp directory that needs to be cleaned up even if the workflow fails for any reason (and to communicate to the user that workflow fails)
We use WorkflowExecutionTimeout to set the max time duration for the workflow
The question is, what is the recommended way to run a cleanup activity (and report failure to the user) if workflow fails for ANY reason?
No. The whole idea of termination is that it is a hard kill that terminates a workflow without any chance of cleanup. If you need to perform cleanup, use workflow cancellation. Or if you need to perform cleanup after some time use timers inside the workflow code.
We solved this issue by using a parent workflow which runs the target workflow as “Child Workflow”
This enabled us to get the child workflow timeout error and handle it properly