abf1312cf5
Test / test (pull_request) Successful in 15m33s
Refresh tokens are single-use since the rotation change (PR #136). Two in-flight requests hitting 401 together (replay upload racing a manual sync) both called /api/auth/refresh; the second presented an already- consumed token, got rejected, and surfaced as a spurious 'session expired' re-login prompt. refresh_token() now takes the stale access token that earned the 401 and runs behind a tokio::sync::Mutex; a loser of the lock race that finds the stored token already rotated returns Ok and retries with it instead of spending the new refresh token. Untested caveat: exercising the race in a unit test needs an in-memory auth_tokens double (the real keyring is unavailable on headless Linux runners) — noted for a future test-support addition. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>