Skip to content

fix: retry message fetch when session encryption not ready#262

Merged
bra1nDump merged 1 commit intoslopus:mainfrom
kmizzi:fix/message-fetch-race-condition
Dec 6, 2025
Merged

fix: retry message fetch when session encryption not ready#262
bra1nDump merged 1 commit intoslopus:mainfrom
kmizzi:fix/message-fetch-race-condition

Conversation

@kmizzi
Copy link
Copy Markdown
Contributor

@kmizzi kmizzi commented Dec 3, 2025

Summary

Fixes the race condition where messages don't load for new sessions when the user quickly navigates to them.

  • When a new session is created and user navigates to it quickly, fetchMessages() may run before fetchSessions() completes
  • Previously, if session encryption wasn't ready, fetchMessages() silently returned early
  • This left the session stuck with isLoaded: false forever (loading spinner)
  • Now we throw an error, which triggers the backoff retry mechanism in InvalidateSync
  • Messages will load once session encryption becomes available

Test plan

  • TypeScript type checking passes (yarn typecheck)
  • Existing sync-related tests pass
  • Manual test: Start session from CLI, quickly open on mobile - messages should load

Fixes #260

🤖 Generated with Claude Code

When a new session is created and the user quickly navigates to it,
fetchMessages() may run before fetchSessions() completes and initializes
the session encryption. Previously, this case silently returned early,
leaving the session with no messages loaded (isLoaded: false forever).

Now we throw an error when encryption isn't ready, which triggers the
backoff retry mechanism in InvalidateSync. This allows the message fetch
to succeed once session encryption becomes available.

Fixes slopus#260

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@bra1nDump
Copy link
Copy Markdown
Contributor

Thanks @kmizzi! Merging this and #263.

Sorry for the long review time - we're resuming active work on the project. Aiming to roll out a new version this weekend.

Contributions welcome! We're discussing plans in Discord: https://discord.gg/aVhXZfYh

@bra1nDump bra1nDump merged commit 5160c61 into slopus:main Dec 6, 2025
imjszhang added a commit to imjszhang/happy that referenced this pull request Dec 19, 2025
slopus#262)

This update improves the message fetching mechanism by throwing an error if session encryption is not ready, triggering a backoff retry. This ensures messages are loaded correctly when a new session is created and the user navigates quickly to it.
JoeLuker pushed a commit to JoeLuker/happy that referenced this pull request Feb 1, 2026
When a new session is created and the user quickly navigates to it,
fetchMessages() may run before fetchSessions() completes and initializes
the session encryption. Previously, this case silently returned early,
leaving the session with no messages loaded (isLoaded: false forever).

Now we throw an error when encryption isn't ready, which triggers the
backoff retry mechanism in InvalidateSync. This allows the message fetch
to succeed once session encryption becomes available.

Fixes slopus#260

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Messages don't load for new sessions due to race condition

2 participants