-
Notifications
You must be signed in to change notification settings - Fork 112
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
Always close response body in CloseRead #515
Conversation
If we fail to discard bytes, we should still close the response body.
@@ -180,6 +180,7 @@ func (d *duplexHTTPCall) CloseRead() error { | |||
return nil | |||
} | |||
if err := discard(d.response.Body); err != nil { | |||
_ = d.response.Body.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we migrate to Go 1.20+, we could use errors.Join(...) in places like this. I didn't want to pull in a new dependency on multierr or other third party packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems straight-forwardly correct to me, LGTM and good catch.
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/bufbuild/connect-go](https://togithub.com/bufbuild/connect-go) | require | minor | `v1.7.0` -> `v1.8.0` | --- ### Release Notes <details> <summary>bufbuild/connect-go</summary> ### [`v1.8.0`](https://togithub.com/bufbuild/connect-go/releases/tag/v1.8.0) [Compare Source](https://togithub.com/bufbuild/connect-go/compare/v1.7.0...v1.8.0) #### What's Changed ##### Enhancements - Expose HTTP method of unary requests (see [documentation][http-method-docs]) by [@​jhump](https://togithub.com/jhump) and [@​akshayjshah](https://togithub.com/akshayjshah) in [https://github.com/bufbuild/connect-go/pull/502](https://togithub.com/bufbuild/connect-go/pull/502) and [https://github.com/bufbuild/connect-go/pull/509](https://togithub.com/bufbuild/connect-go/pull/509) - Implement `fmt.Stringer` interface for StreamType to improve debug logging by [@​svrana](https://togithub.com/svrana) in [https://github.com/bufbuild/connect-go/pull/495](https://togithub.com/bufbuild/connect-go/pull/495) ##### Bugfixes - Fix documentation comments to use correct identifier name by [@​cuishuang](https://togithub.com/cuishuang) in [https://github.com/bufbuild/connect-go/pull/498](https://togithub.com/bufbuild/connect-go/pull/498) - Fix Makefile quotes to handle paths with spaces by [@​bufdev](https://togithub.com/bufdev) in [https://github.com/bufbuild/connect-go/pull/508](https://togithub.com/bufbuild/connect-go/pull/508) - Always close response body in `CloseRead` by [@​pkwarren](https://togithub.com/pkwarren) in [https://github.com/bufbuild/connect-go/pull/515](https://togithub.com/bufbuild/connect-go/pull/515) #### New Contributors - [@​cuishuang](https://togithub.com/cuishuang) made their first contribution in [https://github.com/bufbuild/connect-go/pull/498](https://togithub.com/bufbuild/connect-go/pull/498) - [@​svrana](https://togithub.com/svrana) made their first contribution in [https://github.com/bufbuild/connect-go/pull/495](https://togithub.com/bufbuild/connect-go/pull/495) **Full Changelog**: bufbuild/connect-go@v1.7.0...v1.8.0 [http-method-docs]: https://connect.build/docs/go/get-requests-and-caching#distinguishing-get-requests </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/open-feature/flagd). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMDIuMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNS4xMDIuMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
If we fail to discard bytes, we should still close the response body.
If we fail to discard bytes, we should still close the response body.