From bedf6e90d2b1d4620eb18fa38f211aec8edbabec Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 2 Nov 2020 16:49:27 +0000 Subject: [PATCH] onedrive: warn on gateway timeout errors It seems that when doing chunked uploads to onedrive, if the chunks take more than 3 minutes or so to upload then they may timeout with error 504 Gateway Timeout. This change produces an error (just once) suggesting lowering `--onedrive-chunk-size` or decreasing `--transfers`. This is easy to replicate with: rclone copy -Pvv --bwlimit 0.05M 20M onedrive:20M See: https://forum.rclone.org/t/default-onedrive-chunk-size-does-not-work/20010/ --- backend/onedrive/onedrive.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go index 3c21e4d6d..8f3f5e69d 100755 --- a/backend/onedrive/onedrive.go +++ b/backend/onedrive/onedrive.go @@ -427,6 +427,8 @@ var retryErrorCodes = []int{ 509, // Bandwidth Limit Exceeded } +var gatewayTimeoutError sync.Once + // shouldRetry returns a boolean as to whether this resp and err // deserve to be retried. It returns the err as a convenience func shouldRetry(resp *http.Response, err error) (bool, error) { @@ -451,6 +453,10 @@ func shouldRetry(resp *http.Response, err error) (bool, error) { fs.Debugf(nil, "Too many requests. Trying again in %d seconds.", retryAfter) } } + case 504: // Gateway timeout + gatewayTimeoutError.Do(func() { + fs.Errorf(nil, "%v: upload chunks may be taking too long - try reducing --onedrive-chunk-size or decreasing --transfers", err) + }) case 507: // Insufficient Storage return false, fserrors.FatalError(err) }