@@ -41,6 +41,7 @@ class AlarmManager {
4141 const account = await Account . get ( accountId )
4242 const data = account . getData ( )
4343 const lastSync = data . lastSync || 0
44+ const lastAttempt = data . lastAttempt || 0
4445 const interval = data . syncInterval || DEFAULT_SYNC_INTERVAL
4546 if ( data . scheduled ) {
4647 await this . ctl . scheduleSync ( accountId )
@@ -50,7 +51,7 @@ class AlarmManager {
5051 continue
5152 }
5253 if ( data . error && data . errorCount > 1 ) {
53- if ( Date . now ( ) > this . getBackoffInterval ( interval , data . errorCount , lastSync ) + lastSync ) {
54+ if ( Date . now ( ) > this . getBackoffInterval ( interval , data . errorCount ) + lastAttempt ) {
5455 await this . ctl . scheduleSync ( accountId )
5556 continue
5657 }
@@ -59,7 +60,7 @@ class AlarmManager {
5960 if (
6061 data . syncIntervalEnabled &&
6162 Date . now ( ) >
62- interval * 1000 * 60 + data . lastSync
63+ interval * 1000 * 60 + lastSync
6364 ) {
6465 await this . ctl . scheduleSync ( accountId )
6566 }
@@ -75,10 +76,9 @@ class AlarmManager {
7576 *
7677 * @param {number } interval - The synchronization interval in minutes.
7778 * @param {number } errorCount - The number of consecutive errors encountered.
78- * @param {number } lastSync - The timestamp of when the last successful sync happened.
7979 * @returns {number } - The calculated backoff interval in milliseconds.
8080 */
81- getBackoffInterval ( interval , errorCount , lastSync ) {
81+ getBackoffInterval ( interval , errorCount ) {
8282 return Math . min ( MAX_BACKOFF_INTERVAL , interval * 1000 * 60 * Math . pow ( 2 , errorCount ) )
8383 }
8484}
0 commit comments