Skip to content

fix: close resp body #945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2024
Merged

fix: close resp body #945

merged 1 commit into from
Sep 4, 2024

Conversation

testwill
Copy link
Contributor

No description provided.

@tristanmorgan
Copy link
Member

I think a better fix would be to use the following just after the client.Do(req) on line 48:

if resp != nil {
   defer resp.Body.Close()
}

@aaronhurt
Copy link
Member

bonus for catching the error in an anon func and logging it ...

defer func() {
  if err := rest.Body.Close(); err != nil {
    log-error-here
  }()

Signed-off-by: testwill <[email protected]>
Copy link
Member

@tristanmorgan tristanmorgan left a comment

Choose a reason for hiding this comment

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

our coverage for errors in this registry option isn't great but this should solve a potential resource leak.

@tristanmorgan tristanmorgan merged commit c20a401 into fabiolb:master Sep 4, 2024
2 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.

3 participants