From 11cdf77144d75b445f84e831064d0a0bb0c28829 Mon Sep 17 00:00:00 2001 From: Mihai Todor Date: Fri, 5 Oct 2018 22:54:12 +0100 Subject: [PATCH] Fix bug in CompressWithGzip Propagate io.Copy errors through the io.Pipe --- internal/internal.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/internal.go b/internal/internal.go index 0718ce8ec8cf6..6d087ccebcfba 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -223,7 +223,9 @@ func CompressWithGzip(data io.Reader) (io.Reader, error) { go func() { _, err = io.Copy(gzipWriter, data) gzipWriter.Close() - pipeWriter.Close() + // subsequent reads from the read half of the pipe will + // return no bytes and the error err, or EOF if err is nil. + pipeWriter.CloseWithError(err) }() return pipeReader, err