fix metadata resp.Body leak by grey3228 · Pull Request #6313 · moby/buildkit (original) (raw)

was reading the docs for this

If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close. If the Body is not both read to EOF and closed, the Client's underlying RoundTripper (typically Transport) may not be able to re-use a persistent TCP connection to the server for a subsequent "keep-alive" request.

So it looks like we should not only close but also read to io.Discard. Not sure if it makes any difference in practice.