From 853a686994de7c46be92f7f29d88baa62161800d Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 10 Aug 2024 18:06:24 +0200 Subject: [PATCH] backend: return correct error on upload/request timeout --- internal/backend/watchdog_roundtriper.go | 3 +++ internal/backend/watchdog_roundtriper_test.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/backend/watchdog_roundtriper.go b/internal/backend/watchdog_roundtriper.go index e3e10d7fe..dc270b974 100644 --- a/internal/backend/watchdog_roundtriper.go +++ b/internal/backend/watchdog_roundtriper.go @@ -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 } diff --git a/internal/backend/watchdog_roundtriper_test.go b/internal/backend/watchdog_roundtriper_test.go index bc43447e1..a852029ca 100644 --- a/internal/backend/watchdog_roundtriper_test.go +++ b/internal/backend/watchdog_roundtriper_test.go @@ -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())