You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: recover background tracking after storage errors and failed starts
Two ways the foreground GPS service went dark for the rest of a trip
with nothing left running to bring it back:
- readTrackedJob collapsed "no job" and "AsyncStorage read failed"
into the same null. The background task treated both as "trip over"
and stopped the location service - so one transient storage error
permanently ended tracking mid-job.
- startTracking returns false when the app is backgrounded (expo
refuses to start a foreground service from there) or when background
location permission isn't granted yet, and every caller discarded
that result. Android can also kill the foreground service on its
own (OEM battery managers, low memory). Nothing ever asked again.
Now:
- readTrackedJobResult distinguishes ok/none/error; the task only
stops the service on a genuine "none", and skips the tick on "error"
instead of tearing tracking down
- a watchdog re-asserts tracking on every foreground transition and on
a 60s timer, restarting the service whenever a job is tracked but
isTaskRunning() is false
Also, two smaller correctness fixes paired with today's backend
change (admit mobile fixes by their own timestamp against MQTT
coverage, not by whether streaming happened to be on when they land):
- stop_location_stream now flushes the queue before clearing the
local `streaming` flag, so the tail of a fallback episode is sent
while it can still be attributed to the hole it covers
- flushQueue keeps a batch when the server reports it failed to store
it (res.data.retry), instead of deleting on any 200; deliberate
rejections (redundant/no active job) are still dropped so the queue
doesn't loop forever resending data the server will never accept
Verified against the new backend's response contract for a
not-yet-updated app (scripts/testOldAppCompat.mjs in the backend
repo) - this app's own outstanding requests keep working unchanged.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cd88t6Vx7ToS9ZiqcgMY7v