·7 min read
A courier who stood still stopped receiving offers
The symptom was simple to state and hard to see. A courier switched on their shift and waited for work. Nothing was wrong on screen: the switch said they were available, the app said it was sharing location, the offer list was there. But the offers did not move with them. A courier who drove across town and parked was shown a feed built for where they used to be. I spent one long day, 12 Sep 2026, chasing that into four separate causes, and every one of them was invisible from inside the app.
- Project
- Chiti
- Date
- Sep 2026
- Stack
- React Native, Expo Location, TanStack Query
- Commit
- afd49c8, c25f92c, 80a3e6a, 11ddfb6
- Live
- chiti.com.ge
What broke
The feed of available jobs is a pull. The courier's phone asks the server for offers, and the server filters them to a radius around the position it holds for that courier, then orders what survives by distance to the pickup. The position that decides all of that is the one the phone last reported.
So the contract between the app and the server is quiet but strict: while a courier is on shift, keep that position fresh. When that stops working, nothing fails loudly. The server does exactly what it is told, with old data.
That is what made this expensive to find. The app thought it was tracking and the server thought it was ranking, both with a position that had not moved in hours.
What the code showed
There were four layers, and I peeled them one at a time.
The distance gate. Shift tracking was set to report only after moving 250 metres. I had picked it with a reasonable argument: nobody watches this position on a map and the matcher only needs kilometre accuracy. That was true and the conclusion was still wrong, because of who stands still. A courier waiting for work is not moving. That is what waiting is. So the position was written once, when they switched the shift on, and never again. In afd49c8 (Sep 2026) I replaced the distance gate with time alone, 60 seconds in the foreground and two minutes in the background. A side effect that explains how this survived development: a simulator's position is static by definition, so the shift watcher never emitted once while I tested it.
The same commit stopped the background task and restarted it whenever it was already running. The operating system keeps that task alive across app updates, so a build that changed the options kept running the previous build's cadence indefinitely, with nothing to suggest the new one had not taken.
The provider that never answers. Next was accuracy. The shift watcher asked for the balanced setting, which on Android resolves to network and passive location. A device with no usable network location source then produces no fixes at all, with no error, because asking a provider that never answers is not a failure any API reports. An emulator is exactly such a device, which is why a courier on shift in development reported once and froze, while the same app on a live job moved a customer's map every few seconds. The job mode asks for high accuracy, which is the GPS provider the emulator does feed. c25f92c (Sep 2026) switched shift tracking to high accuracy, foreground and background, and left the power saving to the interval.
A real phone has network location, so this one cost nothing in the field. It only made the feature untestable everywhere else.
The status that lied. The shift screen said "sharing your location so nearby orders can find you". It said so whenever the permission was granted. If the foreground watcher had refused to start, the failure was logged and dropped, and the caller was told the start succeeded either way. 80a3e6a (Sep 2026) made the start report whether the foreground watcher is actually running, and the screen now treats a watcher that did not start like a refused permission, with the notice that says the location is not reaching us.
The cache that outlived the shift. The last layer was not about positions at all. Turning the shift off disables the offers query, but disabling a query stops the request, not the data already in the cache. That cache is persisted to local storage, so a courier who was on shift yesterday opened the app to a full list of claimable offers sitting under a switch that said location was not being shared. Every row was stale by definition. And when the shift is switched on, the query is enabled before the tracker has written the first position, so the first fetch is ranked around whatever the server held before.
The fix
11ddfb6 (Sep 2026) handled both halves of that.
The shift gate moved into the query's select, so every reader of the hook gets the same answer: off shift, the list is empty, whatever is cached.
// enabled stops the request, select stops the cached answer being read
const visible = (offers) => (onShift ? withoutDeclined(offers) : NONE);And the feed now refetches when the server learns where the courier is. It subscribes to the moment a position write has landed, which is the earliest a refetch can get a different answer, and invalidates the offers when the courier has moved far enough to change the ranking. A fix reported before the screen mounted is handled by reading the last reported position at start.
| Before | After | |
|---|---|---|
| Shift report gate | 250 m of movement | Time only, 60 s foreground, 120 s background |
| Accuracy on shift | Balanced | High |
| "Sharing location" | Shown on permission alone | Shown only if a watcher is running |
| Offers off shift | Persisted cache still shown | Empty |
| First fetch on shift | Before the first position | Refetched after the position lands |
The 250 metres came back in a different job. In the refetch rule it is the distance the courier must move before the list is worth re-ranking, because the server filters to a 15 km radius and a few hundred metres changes the order of two nearby offers, not which ones exist. The same number was wrong as a gate on reporting and right as a threshold for asking again.
What I would do differently
I would not have gated a report on distance in the first place. A gate on a signal means silence is ambiguous: it can mean the courier is waiting or that the pipeline is broken. A heartbeat on a timer removes the ambiguity, and the cost, one fix a minute, is small next to a courier who sits invisible for a shift.
I would also have made the offer feed show its own age. The worst part of this bug was that a stale list looks authoritative. A small "ranked for your position at" cue would have turned a silent failure into a visible one.
Where this fits
This is the end of a chain: the socket had to stay up, positions had to be stored, and then the app had to keep sending them for someone who is, by definition, not going anywhere. The bigger picture of how Chiti's real-time layer works, and the other fixes made on real devices, is in the full Chiti case study.
The full project story shows how the position path and the offer feed were built and what else real devices taught me.
Read the full case study#react-native#expo-location#tanstack-query#debugging
Keep reading
Have a project in mind?