Skip to content

Commit

Permalink
reporter: Fix io.EOF handling
Browse files Browse the repository at this point in the history
The way the if statement was written, if there is an io.EOF error, then
we still first try reading the response object, however, in the io.EOF
case it's null, therefore the if statement needs to be swapped around so
it would never try to read something on the nil pointer if an io.EOF
error is returned.
  • Loading branch information
brancz committed Dec 16, 2024
1 parent 0ea54ad commit 36d35f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion reporter/parca_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func (r *ParcaReporter) reportDataToBackend(ctx context.Context, buf *bytes.Buff
if err != nil && err != io.EOF {
return err
}
if len(resp.Record) == 0 || err == io.EOF {
if err == io.EOF || len(resp.Record) == 0 {
// The backend didn't want any more information.
return nil
}
Expand Down

0 comments on commit 36d35f7

Please sign in to comment.