Skip to content

Commit f4e54ce

Browse files
committed
fix: Fix getBackoffInterval logic in BrowserController and NativeController
fixes #2196 Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 851d670 commit f4e54ce

2 files changed

Lines changed: 2 additions & 12 deletions

File tree

src/lib/browser/BrowserController.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,7 @@ class AlarmManager {
7070
* @returns {number} - The calculated backoff interval in milliseconds.
7171
*/
7272
getBackoffInterval(interval, errorCount, lastSync) {
73-
const maxErrorCount = Math.log2(MAX_BACKOFF_INTERVAL / (interval * 1000 * 60))
74-
if (errorCount < maxErrorCount || lastSync + MAX_BACKOFF_INTERVAL < Date.now()) {
75-
return Math.min(MAX_BACKOFF_INTERVAL, interval * 1000 * 60 * Math.pow(2, errorCount))
76-
} else {
77-
return MAX_BACKOFF_INTERVAL + MAX_BACKOFF_INTERVAL * (errorCount - maxErrorCount)
78-
}
73+
return Math.min(MAX_BACKOFF_INTERVAL, interval * 1000 * 60 * Math.pow(2, errorCount))
7974
}
8075
}
8176

src/lib/native/NativeController.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ class AlarmManager {
7979
* @returns {number} - The calculated backoff interval in milliseconds.
8080
*/
8181
getBackoffInterval(interval, errorCount, lastSync) {
82-
const maxErrorCount = Math.log2(MAX_BACKOFF_INTERVAL / (interval * 1000 * 60))
83-
if (errorCount < maxErrorCount || lastSync + MAX_BACKOFF_INTERVAL < Date.now()) {
84-
return Math.min(MAX_BACKOFF_INTERVAL, interval * 1000 * 60 * Math.pow(2, errorCount))
85-
} else {
86-
return MAX_BACKOFF_INTERVAL + MAX_BACKOFF_INTERVAL * (errorCount - maxErrorCount)
87-
}
82+
return Math.min(MAX_BACKOFF_INTERVAL, interval * 1000 * 60 * Math.pow(2, errorCount))
8883
}
8984
}
9085

0 commit comments

Comments
 (0)