diff --git a/tools/amplify-preview/amplify.go b/tools/amplify-preview/amplify.go index 5fd18b5a..d19b5ac9 100644 --- a/tools/amplify-preview/amplify.go +++ b/tools/amplify-preview/amplify.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "strings" + "sync" "time" "github.com/aws/aws-sdk-go-v2/service/amplify" @@ -43,6 +44,8 @@ func (amp *AmplifyPreview) FindExistingBranch(ctx context.Context, branchName st data *amplify.GetBranchOutput err error } + var wg sync.WaitGroup + wg.Add(len(amp.appIDs)) resultCh := make(chan resp, len(amp.appIDs)) for _, appID := range amp.appIDs { @@ -56,10 +59,12 @@ func (amp *AmplifyPreview) FindExistingBranch(ctx context.Context, branchName st data: branch, err: err, } - }() } + wg.Wait() + close(resultCh) + failedResp := aggregatedError{ perAppErr: map[string]error{}, message: "failed to fetch branch",