iOS app multipart upload restarts from zero when switching between 5G and Wi‑Fi during transfer (React Native background uploader)
Environment
React Native app running on iPhone 14 Pro (iOS 17.2). Uploads use a JS-managed background queue with native NSURLSessionUploadTask (NSURLSessionBackgroundConfiguration). Server accepts chunked multipart uploads with Range headers and supports resumable offsets.
Symptoms
When a user starts a large file upload on 5G and moves into Wi‑Fi range (or vice versa), the uploader restarts from 0% rather than resuming at the last byte. The app logs show a new upload task created and the server receiving a fresh POST instead of a range continuation. This occurs unpredictably during a network handoff; small uploads unaffected.
Observations
Console logs show the original NSURLSession background task transitions to 'completed' with an error indicating 'network connection lost' at the same instant a new task is scheduled by the JS layer. The server shows a short-lived connection followed by a separate new connection with no 'Range' or 'Upload-Offset' header. Testing with a native iOS sample app using background NSURLSessionResumeData successfully resumes on handoff, indicating server-side resume works and that background resume behavior differs between native and RN wrapper implementation.
Already attempted
Wrapped upload in a persistent native module bridging RN -> native NSURLSession (migrated from pure JS), but still saw restarts when the RN JS engine process was suspended or terminated. Enabled background modes and ensured proper application:didFinishLaunchingWithOptions: and delegates are present. Attempted to persist resume data to disk on URLSession:task:didCompleteWithError: but observed resumeData is nil when task is cancelled by OS during handoff.
Question
What causes background NSURLSession uploads to restart from zero specifically during cellular/Wi‑Fi handoffs in a React Native app, and what practical changes can ensure resumable transfers without requiring users to remain on a single network?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Programming23% match
Node.js/Express server CPU spikes and event loop stalls during concurrent multipart image uploads due to synchronous image processing
Open0 answers - Mobile21% match
Android 12 app upload worker restarts from zero after app process killed, due to WorkManager using non-persistent foreground service notification
Open0 answers