Skip to content

Conversation

@alltheseas
Copy link
Contributor

@alltheseas alltheseas commented Dec 19, 2025

Summary

  • Profile metadata (kind 0) was never refreshed after initial cache - background refresh only fetched notes (kind 1)
  • Added fetch_profile_metadata() that runs in parallel with note fetching
  • Best-effort: failures don't block note refresh, just log warnings

Test plan

  • Verified locally - stale profiles now update on page visit
  • Check logs for any "failed to stream profile metadata" warnings under normal operation

Fixes #52

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Enhanced profile loading by fetching profile metadata in parallel with profile feed data, reducing overall load time and improving responsiveness.
    • Simplified profile data retrieval by automating relay discovery internally, streamlining the data fetching process.

✏️ Tip: You can customize this high-level summary in your review settings.

Previously, background profile refreshes only fetched kind 1 (notes),
never updating kind 0 (profile metadata). This caused profiles to remain
stale indefinitely after initial cache.

Now fetch_profile_feed also fetches the latest profile metadata from
relays, allowing nostrdb to update cached profiles with newer versions.

Fixes: damus-io#52

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@alltheseas
Copy link
Contributor Author

There's some "Transient CI" issue

 That's a CI environment issue - Ubuntu mirror returned 404 for uuid-dev. Not related to the code changes.                                                                                  
                                                                                                                                                                                             
  Re-run the CI job - transient mirror issues usually resolve on retry. Or the CI workflow may need apt-get update before the install step.                    

@alltheseas
Copy link
Contributor Author

@jb55 this should fix the stale profile issue reported by @sondreb

@alltheseas
Copy link
Contributor Author

@jb55

@alltheseas
Copy link
Contributor Author

@coderabbitai review please

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

@alltheseas, I'll review the changes now.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

The changes introduce parallel background fetching of profile metadata alongside the main profile feed streaming. The fetch_profile_feed function signature is simplified by removing the explicit relays parameter and deriving it internally via collect_profile_relays. A new private fetch_profile_metadata function handles metadata event processing.

Changes

Cohort / File(s) Summary
Profile Metadata & Feed Refactoring
src/render.rs
Added private async function fetch_profile_metadata to stream and process kind 0 profile metadata events with error handling and logging. Modified fetch_profile_feed signature: removed explicit relays parameter, now derives relay targets internally, and spawns fetch_profile_metadata as a parallel background task without blocking profile feed operations.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant fetch_profile_feed
    participant collect_profile_relays
    participant fetch_profile_metadata
    participant relay_pool as relay_pool<br/>(streaming)
    participant ndb as ndb<br/>(storage)

    Caller->>fetch_profile_feed: invoke(relay_pool, ndb, pubkey)
    fetch_profile_feed->>collect_profile_relays: get relays for pubkey
    collect_profile_relays-->>fetch_profile_feed: relays
    
    par Parallel Execution
        fetch_profile_feed->>fetch_profile_metadata: spawn task(relay_pool, ndb, relays, pubkey)
        fetch_profile_metadata->>relay_pool: stream kind 0 events
        relay_pool-->>fetch_profile_metadata: metadata events
        fetch_profile_metadata->>ndb: process & store events
        fetch_profile_metadata-->>fetch_profile_metadata: error handling & logging
    and
        fetch_profile_feed->>relay_pool: stream profile feed events
        relay_pool-->>fetch_profile_feed: feed events
        fetch_profile_feed->>ndb: process feed data
    end
    
    fetch_profile_feed-->>Caller: Result (non-blocking metadata task)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A metadata refresh, oh what a treat!
Parallel streams make the profile complete,
No more stale caches that refuse to age,
Fresh data dances across the page!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing profile metadata refresh during background updates.
Linked Issues check ✅ Passed The PR successfully addresses issue #52 by implementing fetch_profile_metadata to refresh stale profile cache alongside note fetching.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing stale profile cache by adding parallel metadata refresh; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad9d797 and 3ee3476.

📒 Files selected for processing (1)
  • src/render.rs
🧰 Additional context used
🧬 Code graph analysis (1)
src/render.rs (1)
src/relay_pool.rs (1)
  • new (29-59)
🔇 Additional comments (2)
src/render.rs (2)

361-410: Clean, best‑effort metadata refresh logic.

The new helper is scoped, handles empty relay lists, and logs errors without disrupting the main refresh flow. Looks solid for the intended “best‑effort” behavior.


412-427: All call sites have been correctly updated to the new fetch_profile_feed signature. The three callers in src/main.rs (lines 271, 295, and 317) all pass only the three required arguments (pool, ndb, pubkey) without the relays parameter, matching the function definition at src/render.rs:412.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

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.

profile cached version is old

1 participant