Handle HTTP errors

This commit is contained in:
Till Faelligen 2022-09-07 15:44:33 +02:00
parent bdf9b2cee3
commit 5518f985ba
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -407,10 +407,13 @@ userLoop:
waitTime = e.RetryAfter waitTime = e.RetryAfter
} else if e.Blacklisted { } else if e.Blacklisted {
waitTime = time.Hour * 8 waitTime = time.Hour * 8
} else { break userLoop
} else if e.Code > 0 {
// We didn't get a real FederationClientError (e.g. in polylith mode, where gomatrix.HTTPError
// are "converted" to FederationClientError), but we probably shouldn't hit them every $waitTime seconds.
waitTime = time.Hour waitTime = time.Hour
break userLoop
} }
break userLoop
case net.Error: case net.Error:
// Use the default waitTime, if it's a timeout. // Use the default waitTime, if it's a timeout.
// It probably doesn't make sense to try further users. // It probably doesn't make sense to try further users.
@ -420,8 +423,9 @@ userLoop:
break userLoop break userLoop
} }
case gomatrix.HTTPError: case gomatrix.HTTPError:
// The remote server returned an error, give it some time to recover // The remote server returned an error, give it some time to recover.
if e.Code >= 500 { // This is to avoid spamming remote servers, which may not be Matrix servers anymore.
if e.Code >= 300 {
waitTime = time.Minute * 10 waitTime = time.Minute * 10
logrus.WithError(e).Error("GetUserDevices returned gomatrix.HTTPError") logrus.WithError(e).Error("GetUserDevices returned gomatrix.HTTPError")
break userLoop break userLoop