From c76a809919c39e4be19fbcee86244f68b15eac21 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 13 Aug 2025 00:32:59 +1000 Subject: [PATCH] Try harder to pass useful error on webseed read chunks cancellation --- webseed/client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webseed/client.go b/webseed/client.go index e9b7cc26..b74abca8 100644 --- a/webseed/client.go +++ b/webseed/client.go @@ -146,7 +146,7 @@ func (ws *Client) StartNewRequest(ctx context.Context, r RequestSpec, debugLogge requestParts = append(requestParts, part) } // Technically what we want to ensure is that all parts exist consecutively. If the file data - // isn't consecutive, then it is piece aligned and we wouoldn't need to be doing multiple + // isn't consecutive, then it is piece aligned and we wouldn't need to be doing multiple // requests. TODO: Assert this. panicif.Zero(len(requestParts)) body, w := io.Pipe() @@ -202,10 +202,10 @@ func (me *Client) recvPartResult(ctx context.Context, w io.Writer, part requestP if part.responseBodyWrapper != nil { body = part.responseBodyWrapper(body) } - // Prevent further accidental use - resp.Body = nil + // We did set resp.Body to nil here, but I'm worried the HTTP machinery might do something + // funny. if ctx.Err() != nil { - return ctx.Err() + return context.Cause(ctx) } switch resp.StatusCode { case http.StatusPartialContent: -- 2.51.0