Phase 4.4: Sync retry logic, transaction safety, and SyncResult#286
Merged
nbhansen merged 1 commit intoaau-giraf:dev-mainfrom Feb 8, 2026
Merged
Conversation
- Create RetryHelper utility with exponential backoff + jitter for HTTP calls (configurable max attempts, non-retryable status codes 401/403/404) - SyncDownloader: wrap API calls in RetryHelper.runHttp(), batch DB writes inside SQLite transactions, return DownloadResult with EntitySyncStats - SyncUploader: wrap multipart uploads and postAsJson in RetryHelper, return UploadResult with EntitySyncStats and SyncError details - Replace bool return from syncFromServer() with SyncResult containing per-entity-type download/upload stats, error list, timing - Add SyncResult, EntitySyncStats, SyncError to sync_models.dart - SyncTimer: exponential backoff on consecutive failures (30s -> 60s -> 120s -> max 5min), reset to default on success - Mark Phase 4.4 complete in improvementPlan.md
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.
Summary
Implements Phase 4.4 of the improvement roadmap — sync retry logic, SQLite transaction safety, and structured sync results.
Changes
New:
RetryHelperutility (lib/src/utilities/retry_helper.dart)run<T>()for any async operation with retryrunHttp()that inspects status codes before retryingRetryResult<T>with value, success flag, and attempt countNew:
SyncResultmodel (added tosync_models.dart)EntitySyncStats: per-entity-type succeeded/failed/skipped countsSyncError: detailed error record with entity type, ID, message, timestampSyncResult: aggregated result replacingboolreturn fromsyncFromServer()success/partialgettersSyncResult.aborted()factory for early-exit casesSyncDownloader — retry + transactions + stats
RetryHelper.runHttp()RetryHelper.run()db.transaction()per entity typeDownloadResultwith synced IDs +EntitySyncStats+ errorsSyncUploader — retry + stats
RetryHelper.run()RetryHelper.runHttp()via ApiProviderUploadResultwithEntitySyncStats+ errorsSyncService — structured return type
syncFromServer()returnsSyncResultinstead ofboolautoSync()also returnsSyncResultSyncTimer — exponential backoff on failures
Timer()instead ofTimer.periodic()for dynamic intervalsTesting
flutter analyze: 0 errors in modified filesflutter test: 13/13 passdotnet build: 0 errorsFiles changed (7)
+lib/src/utilities/retry_helper.dart~lib/src/services/sync_downloader.dart~lib/src/services/sync_uploader.dart~lib/src/services/sync_service.dart~lib/src/services/sync_timer.dart~lib/src/services/sync_models.dart~improvementPlan.md