Fix sync worker stall on persistent errors#1305
Open
Left024 wants to merge 2 commits into
Open
Conversation
- SyncWorker: cap retry at 3 attempts, then fail to let periodic reset; use accountId from inputData to dispatch correct service type - ReaderWorker: cap retry to avoid blocking POST_SYNC_WORK chain indefinitely - AbstractRssRepository: extract reschedulePeriodicWork() for reuse - AccountViewModel: reschedule periodic tasks immediately after account switch or sync setting change - FeverRssService: use retry instead of failure for consistency
- SyncWorker.enqueuePeriodicWork: use CANCEL_AND_REENQUEUE for ENQUEUED state (only keep UPDATE for RUNNING), so that lastEnqueueTime is reset to current system time on every app start - WidgetUpdateWorker.enqueuePeriodicWork: same treatment - This prevents a one-time clock anomaly from permanently polluting the nextScheduleTimeMillis (symptom: always showing Aug 17 regardless of real date)
Author
追加修复:周期任务 Next scheduled time 永久显示错误日期现象故障排除页面的 Worker infos 中,周期任务 "Next scheduled time" 有时显示为 Aug 17(无论真实日期是多少),且一旦出现就永不恢复。 根因
修复
每次 App 启动时 测试@Left024 已在设备上验证修复有效。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Credits
This change was made by DeepSeek V4 Pro and has been manually tested by @Left024 on device — verified working correctly.
Problem
When background sync encounters an error (e.g., FreshRSS credentials expire, network issues), the SyncWorker enters infinite exponential backoff (capped at 5h). Users experience this as "auto-refresh stopped working completely" — it never recovers until manual refresh or app restart.
Additional issues:
Root Cause
sync()returnsResult.Retry()→ WorkManager exponential backoff. Each retry doubles the wait, permanently suspending the normal sync interval rhythmenqueuePeriodicWorkbakesaccountIdintoinputData, butdoWork()usesrssService.get()(current account type) — cross-account dispatch fails with type checksPOST_SYNC_WORKnever completes → subsequent syncs can't enqueue new ReaderWorker/WidgetUpdateWorkerinitSync()Changes
Result.Failure— for periodic tasks this triggersresetPeriodic(), allowing the next sync interval to proceed normally. Also injectingAccountServiceto dispatch byinputData.accountIdinstead of current accountPOST_SYNC_WORKchain indefinitely; missing full content will be re-fetched by the next sync cyclereschedulePeriodicWork(account)frominitSync()for external reusereschedulePeriodicWorkimmediately on account switch and sync setting changes, no longer requires app restartResult.Failure()toResult.Retry()for behavior consistency with Local/GoogleReader