You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The NopCloser doesn't actually close the request Body which annoys static analyzers and is probably going to create issues. Research whether the http library needs the response closed and what we can do to copy the response in a way that is useful to the new functionality exposing the request.
To Reproduce
Update DoWithContext's defer func in govultr.go to do something like this:
This was added to allow us to return the request for use in the package, but, I'm concerned that it's going to leave connections open. Will need to test this further at some point.
Expected behavior
All http requests will close after completion
Desktop (please complete the following information where applicable:
OS: ubuntu 22.04
Language Version: go 1.20
Browser: na
Version: v3.1.0
Additional context
Golanci-lint calls bodyclose which tipped me off that something wasn't quite right here.
block_storage.go:121:33: response body must be closed (bodyclose)
_, err = b.client.DoWithContext(ctx, req, nil)
^
block_storage.go:133:33: response body must be closed (bodyclose)
_, err = b.client.DoWithContext(ctx, req, nil)
^
block_storage.go:171:33: response body must be closed (bodyclose)
_, err = b.client.DoWithContext(ctx, req, nil)
The text was updated successfully, but these errors were encountered:
Describe the bug
The NopCloser doesn't actually close the request Body which annoys static analyzers and is probably going to create issues. Research whether the http library needs the response closed and what we can do to copy the response in a way that is useful to the new functionality exposing the request.
To Reproduce
Update
DoWithContext
's defer func ingovultr.go
to do something like this:It shouldn't be able to read the Body, but, the request is replaced by a NopCloser via:
The NopCloser actually just returns nil when you try to close it. https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/io/io.go;l=678
This was added to allow us to return the request for use in the package, but, I'm concerned that it's going to leave connections open. Will need to test this further at some point.
Expected behavior
All http requests will close after completion
Desktop (please complete the following information where applicable:
Additional context
Golanci-lint calls
bodyclose
which tipped me off that something wasn't quite right here.The text was updated successfully, but these errors were encountered: