Hello, I’m trying to obtain relevant data from an activity if a workflow cancels it. The activity does heartbeating and is canceled without issues, however, I can’t find any way of sending details in that case. I am thinking of something like LastHeartbeatDetails in TimeoutError. Is there any way of getting the last heartbeat details there?
Also, I noticed a Details method on CanceledError, but I can’t find what to unmarshal it into - I’m getting a no data available error.
The assumption is that if an activity is canceled, then its result doesn’t matter. What is the use case for getting the last heartbeat data during cancellation?
My current use case is getting partial data from it. I have a long-running activity that accrues consumption while it’s going. After it finishes, this consumption value is added to either the result or the error. If an error occurs, the workflow needs to know that value so that the user is granted back its consumption, as errors are likely system faults.
While this activity is running, a user can request to stop the workflow. In the code, this means that another “stop” activity is triggered, which would lead to the normal stopping of the workflow and the former long-running activity - it is not being directly canceled. However, if the “stop” activity fails with a non-retriable error, we want to cancel the initial activity and still get its partial result. This currently does not seem possible to achieve with the metadata we have about it. I’m also setting the WaitForCancelation option to true, which I initially thought meant that you probably need some results from the activity and would return an appropriate error.
Edit: This data is also included in the activity heartbeat details, so getting the last value would work for my use case, too. This is what I’m doing in the case of timeout errors.
A workaround is to call DescribeWorkflowExecution from an activity before canceling the heartbeating activity. The result of this call contains a list of pending activities including the value of the last reported heartbeat.