258
// The event will be applied before the completion since buffered events are reordered and put at the end of the
259
// batch, after command events from the workflow task.
260
>
_, err := addAndApplyHistoryEvent[CancelRequestedEventDefinition](wf, ctx, func(he *historypb.HistoryEvent) {
nexus_commands.go
261
>
he.Attributes = &historypb.HistoryEvent_NexusOperationCancelRequestedEventAttributes{
262
>
NexusOperationCancelRequestedEventAttributes: &historypb.NexusOperationCancelRequestedEventAttributes{
263
>
ScheduledEventId: attrs.ScheduledEventId,
264
>
WorkflowTaskCompletedEventId: opts.WorkflowTaskCompletedEventID,
265
>
},
266
>
}
267
>
he.UserMetadata = cmd.UserMetadata
268
>
})
269
>
if errors.Is(err, nexusoperation.ErrCancellationAlreadyRequested) {
270
return FailWorkflowTaskError{
271
Cause: enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_NEXUS_OPERATION_ATTRIBUTES,