Cancelling gives a chance for your code (both Workflows and Activities) to react to being cancelled. They can even ignore the cancellation request (by catching and not rethrowing CancelledFailure
).
More info:
Another question I have is how does cancelling work?
An error gets thrown from places the Workflow and Activity is blocked that are cancellation-aware. You can use isCancellation(err)
to check: Temporal TypeScript SDK developer's guide | Temporal Documentation