fix(gopher): preserve partial state when EOF follows context cancellation

This commit is contained in:
2026-06-30 11:05:27 +02:00
parent 760593cdb9
commit 2dbbef3e30
+9
View File
@@ -231,6 +231,15 @@ func (p *Protocol) downloadText(ctx context.Context, reader *bufio.Reader, req *
line, err := reader.ReadString('\n')
if err != nil {
if err == io.EOF {
// The connection may have been closed by our context
// cancellation goroutine (or by the server after the
// client cancelled). If so, the EOF is not a genuine
// end-of-data but a side-effect of the cancel and we
// must persist the partial state before bailing.
if ctx.Err() != nil {
saveGopherResume(req, bytesWritten)
return nil, ctx.Err()
}
break
}
saveGopherResume(req, bytesWritten)