From 89daa9efd1ce206931fa58b2a7374fc791ada67b Mon Sep 17 00:00:00 2001 From: OleFrost <82263101+olefrost@users.noreply.github.com> Date: Sat, 24 Apr 2021 11:44:13 +0200 Subject: [PATCH] onedrive: Work around for random "Unable to initialize RPS" errors OneDrive randomly returns the error message: "InvalidAuthenticationToken: Unable to initialize RPS". These unexpected errors typically caused the entire rclone command to fail. This work around recognizes these errors and marks them for a low level retry, that mostly succeeds. This will make rclone commands complete without being noticeable affected. Fixes: #5270 --- backend/onedrive/onedrive.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go index 7ea8caf34..6bb634024 100755 --- a/backend/onedrive/onedrive.go +++ b/backend/onedrive/onedrive.go @@ -566,6 +566,9 @@ func shouldRetry(ctx context.Context, resp *http.Response, err error) (bool, err if len(resp.Header["Www-Authenticate"]) == 1 && strings.Index(resp.Header["Www-Authenticate"][0], "expired_token") >= 0 { retry = true fs.Debugf(nil, "Should retry: %v", err) + } else if err != nil && strings.Contains(err.Error(), "Unable to initialize RPS") { + retry = true + fs.Debugf(nil, "HTTP 401: Unable to initialize RPS. Trying again.") } case 429: // Too Many Requests. // see https://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online