Fix auth race condition causing frequent logouts
Add per-session-id asyncio.Lock around token refresh to prevent
parallel requests from simultaneously refreshing the same token.
Re-read the session inside the lock so a second request can use
the token already refreshed by the first one.

Stop deleting the auth session on refresh failure — transient
errors (network, race condition, expired refresh token) were
wiping the session and forcing a full re-login.

+ tests for both behaviours.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f045b51 commit 14f2753479ffdab31198bdff0557e9acc7cd7312
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored on 23 May
Showing 2 changed files
View
navi/auth/deps.py
View
tests/unit/auth/test_deps.py