Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/internal_workflow_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var _ DomainClient = (*domainClient)(nil)
const (
defaultDecisionTaskTimeoutInSecs = 10
defaultGetHistoryTimeoutInSecs = 25
minLongPollInterval = 100 * time.Millisecond
)

var (
Expand Down Expand Up @@ -512,6 +513,15 @@ func (wc *workflowClient) GetWorkflowHistory(
var err error
Loop:
for {
// Stop polling the server if the remaining context timeout is too low.
// This prevents unnessesary final call which will result in a timeout anyway.
if deadline, ok := ctx.Deadline(); ok {
remainingTime := deadline.Sub(time.Now())
if remainingTime < minLongPollInterval {
return nil, context.DeadlineExceeded
}
}

err = backoff.Retry(ctx,
func() error {
var err1 error
Expand Down