Fix upload failure modes in UploadService and UploadWorker#22656
Fix upload failure modes in UploadService and UploadWorker#22656
Conversation
- Show toast when publishing without network instead of silently skipping - Recover interrupted media uploads (QUEUED/UPLOADING/FAILED) on service restart with loop prevention via process-lifetime tracking set - Wrap UploadWorker.doWork() in try/catch returning Result.retry() - Change network constraint from NOT_ROAMING to CONNECTED - Add exponential backoff policy (10 min) to work requests - Log warning when onPostUploaded receives event for untracked post Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove stale TODO and 18 lines of commented-out recovery code in unpackMediaIntent(), now superseded by recoverInterruptedMediaUploads() - Remove double blank line in UploadService - Use string template in UploadWorker - Use expression-body for getUploadConstraints() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Generated by 🚫 Danger |
Extract backoff delay literal to a named constant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract helper methods to flatten nested loops and conditionals: - recoverMediaForSite() handles per-site recovery - collectNewMedia() and collectAndResetMedia() handle queue collection - resetToQueued() consolidates state reset + dispatch Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
|
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #22656 +/- ##
==========================================
- Coverage 38.11% 38.10% -0.02%
==========================================
Files 2263 2263
Lines 115897 115943 +46
Branches 16091 16104 +13
==========================================
Hits 44175 44175
- Misses 68096 68142 +46
Partials 3626 3626 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Which editor is this with? |
I didn't modify the Editor config. So, I assume GutembergKit? |
|
@adalpari Scratch that last question, I asked Claude to look into this and it identified the problem. I'll work on a fix for this.
|
Remove startup sanitizeMediaUploadStateForSite() call that races with UploadService.onCreate() recovery, marking media as FAILED before it can be re-queued. Also remove hasValidFile() guard from FAILED media recovery since it rejects content:// URIs and large cached files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unnecessary null checks in onCreate(), merge duplicate collectNewMedia/collectAndResetMedia into a single collectMedia() method, fix stale Javadoc, and use String.format for log message. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
Some of this is duplicated in #22652 so I'll close this and revisit it once that PR is merged. |






Description
Upload failures have long been mentioned in app reviews, so I decided to sic Claude on the problem. It turns out
UploadServiceandUploadWorkerhave several failure modes that cause uploads to silently fail or never recover. This PR addresses six issues across four files:UploadUtils):publishPost()silently skipped the upload with no user feedback. Now shows a "no network" toast.UploadService): Media stuck in QUEUED/UPLOADING/FAILED states was abandoned forever when the service was killed. AddedrecoverInterruptedMediaUploads()inonCreate()with a process-lifetime tracking set to prevent recovery loops. Also removed the stale TODO and commented-out code block that this replaces.UploadWorker):doWork()could crash without returningResult.retry(). Wrapped in try/catch so WorkManager can retry.UploadWorker): Changed fromNOT_ROAMINGtoCONNECTEDso uploads work on roaming networks.UploadWorker): AddedBackoffPolicy.EXPONENTIAL(10 min) to both one-time and periodic work requests.PostUploadHandler):onPostUploadedsilently discarded events for untracked posts. Now logs a warning with post ID, current uploading post ID, and any error details.Testing instructions
Offline publish toast:
Upload recovery after service kill:
UploadWorker resilience: