Workflow Cancellation, returning a (partial) payload

First, apologies if this has been asked before.

Imagine I have two workflows: a parent and a child. The child has a series of 100 tasks, and takes 10m to complete. Now imagine that I cancel the child workflow.

Here’s the challenge: I want the child to return (somehow) it’s progress.

In the child, I’ve tried:

  • Catching CanceledFailure, throwing it away, and letting it return the payload. That doesn’t work, the cancellation is wrapped, the payload isn’t returned.
  • Catching CanceledFailure, then signalling the parent with the payload, but that doesn’t work either. Although, it’s possible I need to do the child’s own child-workflows/activities within a CancellationScope and handle accordingly.

I had wondered if it was possible to add to the details of the CanceledFailure, but that doesn’t look possible.

I also thought about not cancelling the child, but sending a signal to it, and causing it to exit early. But then, how to force the exception? (i.e. something similar to CanceledFailure being generated).

It’s probably possible to put a SideEffect onto the child-workflow, then go and load it – but that’s messy as you have to use the direct APIs.

Any thoughts?

Thank you!

Sean

  • Catching CanceledFailure, then signalling the parent with the payload, but that doesn’t work either. Although, it’s possible I need to do the child’s own child-workflows/activities within a CancellationScope and handle accordingly.

This should work assuming that you signal the parent from a DetachedCancellationScope.

1 Like

That works, thank you!