2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-27 12:42:49 +00:00

Merge pull request #4993 from MichaelEischer/fix-timeout-error

backend: return correct error on upload/request timeout
This commit is contained in:
Michael Eischer 2024-08-15 22:07:37 +02:00 committed by GitHub
commit 74d3f92cc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -65,6 +65,9 @@ func (w *watchdogRoundtripper) RoundTrip(req *http.Request) (*http.Response, err
resp, err := w.rt.RoundTrip(req)
if err != nil {
if isTimeout(err) {
err = errRequestTimeout
}
return nil, err
}

View File

@ -135,7 +135,7 @@ func TestUploadTimeout(t *testing.T) {
rtest.OK(t, err)
resp, err := rt.RoundTrip(req)
rtest.Equals(t, context.Canceled, err)
rtest.Equals(t, errRequestTimeout, err)
// make linter happy
if resp != nil {
rtest.OK(t, resp.Body.Close())
@ -162,7 +162,7 @@ func TestProcessingTimeout(t *testing.T) {
rtest.OK(t, err)
resp, err := rt.RoundTrip(req)
rtest.Equals(t, context.Canceled, err)
rtest.Equals(t, errRequestTimeout, err)
// make linter happy
if resp != nil {
rtest.OK(t, resp.Body.Close())