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
{{ message }}
Repository navigation
Messages don't load for new sessions due to race condition #260
When a new session is started from the CLI, message history may not load on the mobile app due to a race condition between session encryption initialization and message fetching.
Severity
High
Affected
Sessions started from CLI that user quickly navigates to on mobile
Root Cause
The fetchMessages function requires session encryption to be initialized (via fetchSessions), but if the user navigates to a session before fetchSessions completes, fetchMessages silently returns early without fetching messages. The InvalidateSync pattern only retries on thrown errors, not silent returns.
Flow That Fails
CLI creates new session
↓
Server sends "new-session" WebSocket update
↓
Mobile receives update, calls sessionsSync.invalidate()
↓
User navigates to the session (e.g., from push notification)
↓
onSessionVisible(sessionId) is called
↓
fetchMessages() runs BUT encryption isn't ready yet
↓
getSessionEncryption(sessionId) returns NULL
↓
fetchMessages() returns early (silent, no error thrown)
↓
isLoaded stays FALSE, user sees loading spinner forever
↓
fetchSessions() eventually completes, sets up encryption
↓
But fetchMessages was already "completed" - no automatic retry
Key Code Locations
sources/sync/sync.ts:1402-1406 - Early return when encryption not ready
sources/sync/sync.ts:188-194 - onSessionVisible creates the fetch sync
sources/sync/encryption/encryption.ts:90-92 - getSessionEncryption returns null if not initialized
sources/utils/sync.ts - InvalidateSync uses backoff for retries, but only on thrown errors
Reproduction
Start a new Claude Code session from CLI
Quickly open the session on mobile (e.g., via push notification)
Messages may not load, showing loading spinner indefinitely
Potential Fixes
Throw an error instead of returning - Change the early return to throw, triggering backoff retry
Wait for session encryption - Add await sessionsSync.awaitQueue() before fetching messages
Re-invalidate after sessions load - After fetchSessions completes, re-trigger fetchMessages for visited sessions
Queue message fetches - If encryption isn't ready, queue the fetch to run after initialization
Activity
fix: retry message fetch when session encryption not ready
kmizzi commentedon Dec 3, 2025
Fix submitted in PR #262: #262
fix: retry message fetch when session encryption not ready
fix: retry message fetch when session encryption not ready (slopus#262)