Merge pull request #1367 from balena-io/fix-state-fetch-backoff

Fix exponential backoff for state polling
This commit is contained in:
bulldozer-balena[bot] 2020-06-08 15:17:38 +00:00 committed by GitHub
commit 507cb33c6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,13 +141,13 @@ const poll = async (
// Try to fetch latest target state
try {
await update();
// Reset fetchErrors because we successfuly updated
fetchErrors = 0;
} catch (e) {
// Exponential back off if request fails
pollInterval = Math.min(appUpdatePollInterval, 15000 * 2 ** fetchErrors);
++fetchErrors;
} finally {
// Reset fetchErrors because we successfuly updated
fetchErrors = 0;
// Wait to poll again
await delayedLoop(pollInterval);
}