PERF: Add exponential backoff for `/presence/update` errors (#22864)

We already handled 429 rate limit errors correctly. This commit adds backoff logic to other types of error to avoid requests being retried every second.
This commit is contained in:
David Taylor 2023-07-28 22:42:46 +01:00 committed by GitHub
parent 0f1479e896
commit 27cdd724ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -562,6 +562,11 @@ export default class PresenceService extends Service {
const waitSeconds = e.jqXHR.responseJSON?.extras?.wait_seconds || 10;
this._presenceDebounceMs = waitSeconds * 1000;
} else {
// Other error, exponential backoff capped at 30 seconds
this._presenceDebounceMs = Math.min(
this._presenceDebounceMs * 2,
PRESENCE_INTERVAL_S * 1000
);
throw e;
}
} finally {