Skip to content

Commit

Permalink
fix: do done before wait
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Dec 8, 2023
1 parent 6834d31 commit 79fcafb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flow/activities/flowable.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ func (a *FlowableActivity) StartFlow(ctx context.Context,
}

if !hasRecords {
done <- struct{}{}
// wait for the pull goroutine to finish
err = errGroup.Wait()
if err != nil {
Expand Down Expand Up @@ -338,7 +339,7 @@ func (a *FlowableActivity) StartFlow(ctx context.Context,
log.Warnf("failed to push records: %v", err)
return nil, fmt.Errorf("failed to push records: %w", err)
}

done <- struct{}{}
err = errGroup.Wait()
if err != nil {
return nil, fmt.Errorf("failed to pull records: %w", err)
Expand Down Expand Up @@ -386,7 +387,6 @@ func (a *FlowableActivity) StartFlow(ctx context.Context,

pushedRecordsWithCount := fmt.Sprintf("pushed %d records", numRecords)
activity.RecordHeartbeat(ctx, pushedRecordsWithCount)
done <- struct{}{}

return res, nil
}
Expand Down

0 comments on commit 79fcafb

Please sign in to comment.