Skip to content

fix(http): close response bodies on rejected statuses - #157

Merged
rvagg merged 1 commit into
filecoin-project:masterfrom
bensynapse:fix-http-response-cleanup
Oct 5, 2026
Merged

rvagg merged 1 commit into
filecoin-project:masterfrom
bensynapse:fix-http-response-cleanup

Conversation

@bensynapse

Copy link
Copy Markdown
Contributor

I run Live Tennis API.

HTTP status errors return before the client schedules response body cleanup. Repeated 401 or 429 responses can therefore leave bodies open.

Move the existing close defer immediately after a successful Do call. This covers ordinary calls and notifications. Status handling stays the same.

All 12 rejected response cases fail on the original code and pass with the fix. Five controls cover successful responses and error decoding.

I ran go test -shuffle=on -race -v -count=1 ./... in Docker on Go 1.25.14 and 1.26.8. Both pass 112 tests and subtests. The existing large result test skips unless I_HAVE_A_LOT_OF_MEMORY_AND_TIME=1 is set.

Build and vet pass on both versions. Formatting, module tidiness and the workflow's pinned staticcheck pass.

@bensynapse
bensynapse requested a review from rvagg as a code owner October 4, 2026 11:33

@rvagg rvagg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks!

@rvagg
rvagg merged commit 3b625fd into filecoin-project:master Oct 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants