Skip to content

Commit 84bc827

Browse files
authored
fix(miner): fix error handling when reading HTTP response body in GeneratePoRepVanillaProof (#13332)
* Fix error handling when reading HTTP response body in GeneratePoRepVanillaProof After receiving HTTP 200, the function calls io.ReadAll(resp.Body). If ReadAll returns an error the code appends/logs it but does NOT abort/continue; it still closes the body and then returns body, nil. This can return a nil or partially read proof while reporting success, masking errors. This PR fix the issue. * fix: ensure response body is manually closed after reading in GeneratePoRepVanillaProof
1 parent 9ccb5a2 commit 84bc827

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

storage/paths/remote.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,11 +991,12 @@ func (r *Remote) GeneratePoRepVanillaProof(ctx context.Context, sr storiface.Sec
991991

992992
// Read the response body
993993
body, err := io.ReadAll(resp.Body)
994+
_ = resp.Body.Close()
994995
if err != nil {
995996
merr = multierror.Append(merr, xerrors.Errorf("resp.Body ReadAll: %w", err))
996997
log.Warnw("GeneratePoRepVanillaProof read response body failed", "url", url, "error", err)
998+
continue
997999
}
998-
_ = resp.Body.Close()
9991000

10001001
// Return the proof if successful
10011002
return body, nil

0 commit comments

Comments
 (0)