From 43227bf24d098591ea8dc354465b91611273e067 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Tue, 29 Nov 2022 14:04:27 -0700 Subject: [PATCH] server(transfer): fix dead-lock while uploading archive Previously we waited for both the request and multipart writer to "complete", before handing any errors. This lead to a problem where if the request returns before all the data has been read, the upload would become stuck and keep the server in a transferring state when the transfer should've been aborted. Closes https://github.com/pterodactyl/panel/issues/4578 --- server/transfer/source.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/transfer/source.go b/server/transfer/source.go index 2775363..cdcceec 100644 --- a/server/transfer/source.go +++ b/server/transfer/source.go @@ -128,6 +128,13 @@ func (t *Transfer) PushArchiveToTarget(url, token string) ([]byte, error) { t.Log().Debug("sending archive to destination") client := http.Client{Timeout: 0} res, err := client.Do(req) + if err != nil { + t.Log().Debug("error while sending archive to destination") + return nil, err + } + if res.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected status code from destination: %d", res.StatusCode) + } t.Log().Debug("waiting for stream to complete") select { case <-ctx.Done():