Possibly other types of wake-ups could occur too. The motivating issue:
invalid command sequence: [RequestCancelActivityTask, CancelWorkflowExecution, ProtocolMessage, ProtocolMessage], command CancelWorkflowExecution must be the last command.
That sequence was caused by cancelling an activity while also cancelling the workflow. Then Core sent an activation to notify lang that the activity is now cancelled, causing it to wake up again and finish two update handlers, this all being after the workflow had already exited.
This is probably all only possible in situations where this is happening within one WFT.
More likely than not the right way to fix this is to simply not send the activation with the activity getting cancelled, since the workflow already exited there is no point.
Describe the bug
Possibly other types of wake-ups could occur too. The motivating issue:
That sequence was caused by cancelling an activity while also cancelling the workflow. Then Core sent an activation to notify lang that the activity is now cancelled, causing it to wake up again and finish two update handlers, this all being after the workflow had already exited.
This is probably all only possible in situations where this is happening within one WFT.
More likely than not the right way to fix this is to simply not send the activation with the activity getting cancelled, since the workflow already exited there is no point.
Minimal Reproduction
Should be easy to make a UT simulating the above