diff --git a/src/device-state/target-state.ts b/src/device-state/target-state.ts index dd6c755f..0ed936b0 100644 --- a/src/device-state/target-state.ts +++ b/src/device-state/target-state.ts @@ -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); }