diff --git a/internal/internal_activity.go b/internal/internal_activity.go index 89f8f50ad..a75eff882 100644 --- a/internal/internal_activity.go +++ b/internal/internal_activity.go @@ -432,10 +432,9 @@ func deSerializeFunctionResult(f interface{}, result []byte, to interface{}, dat } // For everything we return result. - // TODO(remove comment): - // Code reaches here for 2 cases - // 1. activity is executed by name (not the func pointer) and it wasn't registered - // 2. activity is executed by func pointer and the signature indicates it doesn't/can't return data. + // Code reaches here for 2 cases: + // 1. activity is executed by name (not the func pointer) and it wasn't registered + // 2. activity is executed by func pointer and the signature indicates it doesn't/can't return data. // for example it only has one return parameter (which can only be be error). return decodeArg(dataConverter, result, to) } diff --git a/internal/internal_task_handlers.go b/internal/internal_task_handlers.go index a9f973653..f67d2691d 100644 --- a/internal/internal_task_handlers.go +++ b/internal/internal_task_handlers.go @@ -932,7 +932,8 @@ ProcessEvents: isLast := !isInReplay && i == len(reorderedEvents)-1 if !skipReplayCheck { isDecisionEventFn := isDecisionEvent - if isInReplay { + // when strict nondeterminism is enabled we use a different function to check for decision events during replay + if !w.wth.disableStrictNonDeterminism && isInReplay { isDecisionEventFn = isDecisionEventForReplay } @@ -957,10 +958,15 @@ ProcessEvents: return nil, err } - // Break the event processing loop if the workflow is completed except in replay mode. - // In replay mode we check for nondeterminism cases and - // breaking the loop causes missing events in respondEvents which then causes false positives or false negatives. - if w.isWorkflowCompleted && !isInReplay { + // Break the event processing loop if either + // - Workflow is completed AND strict nondeterminism checks disabled. + // - Workflow is completed AND strict nondeterminism checks enabled AND NOT in replay mode. + // With strict nondeterminism checks enabled, breaking the loop early causes missing events + // in respondEvents which then causes false positives or false negatives. + stopProcessing := (w.isWorkflowCompleted && w.wth.disableStrictNonDeterminism) || + (w.isWorkflowCompleted && !w.wth.disableStrictNonDeterminism && !isInReplay) + + if stopProcessing { break ProcessEvents } } @@ -1046,7 +1052,7 @@ ProcessEvents: // workflow timeout. return nil, nonDeterministicErr default: - panic(fmt.Sprintf("unknown mismatched workflow history policy.")) + panic("unknown mismatched workflow history policy.") } }