All jobs / Mobile developer / Networking
Mobile developer interview question · 3–5 years
On launch the app fires six requests at once. The access token has expired, and some users end up logged out.
What is happening, and what do you build?
The strongest answer
Six parallel failures each start their own refresh, and if the server rotates refresh tokens the later ones spend a token already used. Allow one refresh in flight, queue the callers, then retry each once
Why it works
Exactly — it is a concurrency bug, not an auth bug, and single-flight plus one retry is the whole fix.
What a good answer covers
- One refresh in flight.
- Queue the callers; refresh once.
- Retry each request exactly once.
- Log out only when refresh fails.
Answers that fall short
- Close, but not the strongest: Refresh the token ahead of time using its expiry, before the requests go out
Good hygiene and worth doing, but clock skew and a revoked token still produce concurrent failures, so you still need the lock. - Weak: Retry the failed requests a few times; one of the refreshes usually wins
Blind retries make more refreshes, not fewer, and the losing one is what logs the user out. - Red flag: On any 401 clear the session and send the user to the login screen — that is the safe thing to do
An expired token is the normal case; logging out on it turns a routine refresh into a support ticket.
Who gets asked this
More Networking questions
- Three apps will all work offline. What do you standardise?
- The API was down for ten minutes. It fell over again the moment it returned, and the traffic was the app…
- The backend adds a field to a response and the shipped app starts failing to parse it. What should the client…
- A feed can be tens of thousands of items. How do you load it?
- A notes app edits offline and later meets a server that also changed. What do you do?
- How do you avoid re-downloading a list that rarely changes, without showing stale data for ever?
- You are choosing how a field-sales app syncs. What do you put in the design doc?