Skip to content

Commit

Permalink
Handle case when context is canceled before any results are sent to t…
Browse files Browse the repository at this point in the history
…he results channel
  • Loading branch information
estolfo committed Jul 27, 2021
1 parent 2f1d8e3 commit e48c2c0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sourcemap/fleet_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ func (f fleetStore) fetch(ctx context.Context, name, version, path string) (stri
go func(fleetURL string) {
defer wg.Done()
sourcemap, err := sendRequest(f, ctx, fleetURL)
results <- result{sourcemap, err}
select {
case <-ctx.Done():
case results <- result{sourcemap, err}:
}
}(baseURL + sourceMapURL)
}

Expand All @@ -142,8 +145,10 @@ func (f fleetStore) fetch(ctx context.Context, name, version, path string) (stri
}
}

// All requests resulted in a query failure
return "", err
if err != nil {
return "", err
}
return "", ctx.Err()
}

func sendRequest(f fleetStore, ctx context.Context, fleetURL string) (string, error) {
Expand Down

0 comments on commit e48c2c0

Please sign in to comment.