@@ -328,9 +328,6 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
328328 return errors .New ("first event is not WorkflowExecutionStarted" )
329329 }
330330 last := events [len (events )- 1 ]
331- if last .GetEventType () != shared .EventTypeWorkflowExecutionCompleted && last .GetEventType () != shared .EventTypeWorkflowExecutionContinuedAsNew {
332- return errors .New ("last event is not WorkflowExecutionCompleted or WorkflowExecutionContinuedAsNew" )
333- }
334331
335332 attr := first .WorkflowExecutionStartedEventAttributes
336333 if attr == nil {
@@ -341,6 +338,10 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
341338 RunId : common .StringPtr (uuid .NewUUID ().String ()),
342339 WorkflowId : common .StringPtr ("ReplayId" ),
343340 }
341+ if first .WorkflowExecutionStartedEventAttributes .GetOriginalExecutionRunId () != "" {
342+ execution .RunId = common .StringPtr (first .WorkflowExecutionStartedEventAttributes .GetOriginalExecutionRunId ())
343+ }
344+
344345 task := & shared.PollForDecisionTaskResponse {
345346 Attempt : common .Int64Ptr (0 ),
346347 TaskToken : []byte ("ReplayTaskToken" ),
@@ -372,6 +373,10 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
372373 if err != nil {
373374 return err
374375 }
376+
377+ if last .GetEventType () != shared .EventTypeWorkflowExecutionCompleted && last .GetEventType () != shared .EventTypeWorkflowExecutionContinuedAsNew {
378+ return nil
379+ }
375380 err = fmt .Errorf ("replay workflow doesn't return the same result as the last event, resp: %v, last: %v" , resp , last )
376381 if resp != nil {
377382 completeReq , ok := resp .(* shared.RespondDecisionTaskCompletedRequest )
0 commit comments