React Native Android background multipart upload resets to 0% after switching from cellular to Wi‑Fi
Environment
Android 12 devices running a React Native app using a background uploader library (uploads ~200 MB via multipart POST to company API). App uses a background service but not a foreground persistent notification. Access token expires every 15 minutes; server supports partial uploads only if client provides upload‑session token.
Symptoms
When users switch from 5G to Wi‑Fi mid-upload, the client restarts the upload from 0% and server shows incomplete partial uploads that never continue. This happens consistently when network type changes during transfer.
Observations
Client logs show HTTP connection closed and then a fresh POST started. No 'resume' or range requests attempted. Android OS sometimes kills background service during handover; no foreground notification present. Server returns 401 when token expired; uploader library does not retry with token refresh flow.
Already attempted
Tried increasing token lifetime, adding retry logic at app layer, and keeping socket alive; still restarts when service is killed by OS. Tested with WorkManager and a foreground service; foreground service prevented kills but server still required resumable protocol.
Question
What causes the multipart upload reset on network change and what are the recommended, safe ways to implement resumable background uploads on Android for React Native?
Verified community troubleshooting
This is usually a combination of Android killing a non‑foreground background uploader during handover and the server not supporting resumable uploads. Fix in two parts: (1) make the Android upload resilient — run it under WorkManager/foreground service so it survives network changes and persists progress to disk; (2) implement a resumable protocol server-side (tus or multipart with upload IDs) so the client can reattach and send the remaining bytes after a restart. Short‑term, promoting uploads to a foreground service and ensuring tokens refresh on 401 will reduce restarts; long‑term, add a true resumable upload API. Both steps are reversible and testable by switching networks mid-upload and confirming progress continues rather than restarting.
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Mobile39% match
iOS app multipart upload restarts from zero when switching between 5G and Wi‑Fi during transfer (React Native background uploader)
Open0 answers - Mobile31% match
Android 12 app upload worker restarts from zero after app process killed, due to WorkManager using non-persistent foreground service notification
Open0 answers - Mobile23% match
Android WorkManager background uploads fail with 401 after device Doze — stale auth token persisted in Worker on API 31+
Open1 answer