558
isCloseEventOnly bool,
559
history *historypb.History,
561
>
// Backwards-compatibility fix for retry events after #1866: older SDKs don't know how to "follow"
562
>
// subsequent runs linked in WorkflowExecutionFailed or TimedOut events, so they'll get the wrong result
563
>
// when trying to "get" the result of a workflow run. (This applies to cron runs also but "get" on a cron
564
>
// workflow isn't really sensible.)
565
>
//
566
>
// To handle this in a backwards-compatible way, we'll pretend the completion event is actually
567
>
// ContinuedAsNew, if it's Failed or TimedOut. We want to do this only when the client is looking for a
568
>
// completion event, and not when it's getting the history to display for other purposes. The best signal
569
>
// for that purpose is `isCloseEventOnly`. (We can't use `isLongPoll` also because in some cases, older
570
>
// versions of the Java SDK don't set that flag.)
571
>
//
572
>
// TODO: We can remove this once we no longer support SDK versions prior to around September 2021.
573
>
// Revisit this once we have an SDK deprecation policy.
574
>
followsNextRunId := versionChecker.ClientSupportsFeature(ctx, headers.FeatureFollowsNextRunID)
575
>
if isCloseEventOnly && !followsNextRunId && len(history.Events) > 0 {
576
>
lastEvent := history.Events[len(history.Events)-1]
577
>
fakeEvent, err := makeFakeContinuedAsNewEvent(ctx, lastEvent)
578
>
if err != nil {
579
return err
580
}
582
history.Events[len(history.Events)-1] = fakeEvent
583
}
584
}
586
}
587