Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Persisted queries #1320

Merged
merged 1 commit into from
Dec 11, 2024
Merged

fix: Persisted queries #1320

merged 1 commit into from
Dec 11, 2024

Conversation

alexrisch
Copy link
Collaborator

@alexrisch alexrisch commented Dec 6, 2024

Added persistance by query
Bumped ReactQuery Versions
Added handling to fetch persisted conversations before dismissing the splash screen

Closes #1321

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced hydration logic for fetching conversation lists, improving asynchronous handling and logging.
    • Added persistence for query data in inbox and profile socials queries.
  • Improvements

    • Refactored query configurations for conversation lists to streamline setup and improve maintainability.
  • Dependency Updates

    • Updated several @tanstack library packages to version 5.62.2 for improved performance and stability.

@alexrisch alexrisch requested a review from a team as a code owner December 6, 2024 03:49
Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

Walkthrough

The pull request introduces significant changes to the hydration logic in the HydrationStateHandler component, enhancing how persisted conversation lists are fetched for each account. It employs Promise.allSettled for concurrent fetching and includes detailed logging. Additionally, several query configuration files have been updated to incorporate a new persistence feature using reactQueryPersister. The package.json file reflects updates to specific dependencies, transitioning from caret to exact versioning for certain @tanstack packages, ensuring more controlled dependency management.

Changes

File Change Summary
components/StateHandlers/HydrationStateHandler.tsx Introduced fetchPersistedConversationListQuery function for fetching conversation lists concurrently for each account using Promise.allSettled. Enhanced logging for fetching operations. Retained inactive code for refreshing profiles.
package.json Updated versions of @tanstack packages from caret to exact versioning: @tanstack/query-persist-client-core, @tanstack/query-sync-storage-persister, @tanstack/react-query, @tanstack/react-query-persist-client.
queries/useInboxProfileSocialsQuery.ts Added import for reactQueryPersister and set persister property in inboxProfileSocialsQueryConfig to enable query data persistence.
queries/useProfileSocialsQuery.ts Added import for reactQueryPersister and set persister property in profileSocialsQueryConfig to enable query data persistence.
queries/useV3ConversationListQuery.ts Introduced v3ConversationListQueryConfig for centralized query configuration. Updated several functions to utilize this new configuration, enhancing maintainability and consistency across query setups.

Assessment against linked issues

Objective Addressed Explanation
Don't dismiss Splash screen until persisted conversation list is loaded (#1321)

Possibly related PRs

Suggested labels

2.0.7, 3.0.0

Suggested reviewers

  • thierryskoda

🐰 In the code where rabbits hop,
Hydration flows and never stops.
Fetching lists with great delight,
Logging each fetch, oh what a sight!
Dependencies updated, all in line,
In our code, everything's just fine! 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Dec 6, 2024

Performance Comparison Report

  • Current: 40158d3 - 2024-12-11 16:03:04Z
  • Baseline: release/3.0.0 (c722e78) - 2024-12-11 16:01:24Z

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Type Duration Count
Avatar Image 10 runs render 1.4 ms → 1.2 ms (-0.2 ms, -14.3%) 1 → 1
Avatar Image 50 runs render 1.1 ms → 1.1 ms 1 → 1
Empty Avatar 10 runs render 1.0 ms → 0.7 ms (-0.3 ms, -30.0%) 🟢 1 → 1
Empty Avatar 50 runs render 0.6 ms → 0.6 ms (-0.0 ms, -3.1%) 1 → 1
Text Component with color prop - 10 runs render 0.2 ms → 0.2 ms 1 → 1
Text Component with default props - 10 runs render 0.2 ms → 0.4 ms (+0.2 ms, +100.0%) 🔴 1 → 1
Text Component with translation key - 10 runs render 0.3 ms → 0.1 ms (-0.2 ms, -66.7%) 🟢 1 → 1
Text Component with weight and size - 10 runs render 0.1 ms → 0.2 ms (+0.1 ms, +100.0%) 🔴 1 → 1
Show details
Name Type Duration Count
Avatar Image 10 runs render Baseline
Mean: 1.4 ms
Stdev: 0.5 ms (36.9%)
Runs: 2 1 2 1 1 2 1 2 1 1
Warmup runs: 2

Current
Mean: 1.2 ms
Stdev: 0.4 ms (35.1%)
Runs: 1 1 2 1 1 1 1 1 2 1
Warmup runs: 2
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Avatar Image 50 runs render Baseline
Mean: 1.1 ms
Stdev: 0.3 ms (29.3%)
Runs: 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 2 1 2
Warmup runs: 1

Current
Mean: 1.1 ms
Stdev: 0.4 ms (34.4%)
Runs: 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 2 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 2
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 10 runs render Baseline
Mean: 1.0 ms
Stdev: 0.0 ms (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Warmup runs: 2

Current
Mean: 0.7 ms
Stdev: 0.5 ms (69.0%)
Runs: 1 0 0 1 1 1 0 1 1 1
Warmup runs: 3
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 50 runs render Baseline
Mean: 0.6 ms
Stdev: 0.5 ms (75.8%)
Runs: 1 1 1 0 0 0 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 1
Warmup runs: 1

Current
Mean: 0.6 ms
Stdev: 0.5 ms (79.1%)
Runs: 1 1 1 1 0 1 0 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 1 0 1 1 0 0 1 0 0 0 0 1 0 1 1 1 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with color prop - 10 runs render Baseline
Mean: 0.2 ms
Stdev: 0.4 ms (210.8%)
Runs: 0 0 0 0 0 0 1 1 0 0
Warmup runs: 0

Current
Mean: 0.2 ms
Stdev: 0.4 ms (210.8%)
Runs: 0 0 0 0 0 0 0 1 0 1
Warmup runs: 0
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with default props - 10 runs render Baseline
Mean: 0.2 ms
Stdev: 0.4 ms (210.8%)
Runs: 0 1 0 0 1 0 0 0 0 0
Warmup runs: 0

Current
Mean: 0.4 ms
Stdev: 0.5 ms (129.1%)
Runs: 1 1 1 0 1 0 0 0 0 0
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with translation key - 10 runs render Baseline
Mean: 0.3 ms
Stdev: 0.5 ms (161.0%)
Runs: 0 0 0 0 1 0 0 0 1 1
Warmup runs: 1

Current
Mean: 0.1 ms
Stdev: 0.3 ms (316.2%)
Runs: 0 0 0 1 0 0 0 0 0 0
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with weight and size - 10 runs render Baseline
Mean: 0.1 ms
Stdev: 0.3 ms (316.2%)
Runs: 0 0 0 0 1 0 0 0 0 0
Warmup runs: 1

Current
Mean: 0.2 ms
Stdev: 0.4 ms (210.8%)
Runs: 1 0 0 0 0 1 0 0 0 0
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Render Count Changes

There are no entries

Render Issues

There are no entries

Added Scenarios

There are no entries

Removed Scenarios

There are no entries

Generated by 🚫 dangerJS against 66cea07

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 583d987 and 092da29.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • components/StateHandlers/HydrationStateHandler.tsx (2 hunks)
  • package.json (1 hunks)
  • queries/useInboxProfileSocialsQuery.ts (2 hunks)
  • queries/useProfileSocialsQuery.ts (2 hunks)
  • queries/useV3ConversationListQuery.ts (2 hunks)
🧰 Additional context used
📓 Learnings (1)
queries/useV3ConversationListQuery.ts (1)
Learnt from: alexrisch
PR: ephemeraHQ/converse-app#1313
File: queries/useV3ConversationListQuery.ts:196-268
Timestamp: 2024-12-05T18:33:24.472Z
Learning: In the TypeScript file `queries/useV3ConversationListQuery.ts`, helper functions like `updateGroupImageToConversationListQuery`, `updateGroupNameToConversationListQuery`, and `updateGroupDescriptionToConversationListQuery` are used to reduce dependency on exact types or creating objects that get passed unnecessarily, even though they internally use `updateGroupMetadataToConversationListQuery`.
🔇 Additional comments (4)
queries/useProfileSocialsQuery.ts (1)

11-11: Ensure secure handling of persisted query data

Since the query data is being persisted using reactQueryPersister, verify that any sensitive information within ProfileSocials is securely handled, and consider encrypting the persisted data if necessary.

Also applies to: 48-48

queries/useInboxProfileSocialsQuery.ts (1)

12-12: Ensure secure handling of persisted query data

Since the query data in InboxProfileSocials is being persisted using reactQueryPersister, verify that any sensitive information is securely handled, and consider encrypting the persisted data if necessary.

Also applies to: 52-52

queries/useV3ConversationListQuery.ts (1)

82-92: Refactoring to centralize query configuration improves maintainability

The introduction of v3ConversationListQueryConfig simplifies the query configuration and promotes consistency across the codebase.

package.json (1)

72-75: Confirm the shift to exact versioning for @tanstack dependencies

You've updated the @tanstack dependencies to exact versions. Ensure this change is intentional, as using exact versions will prevent receiving automatic updates that may include important fixes and improvements.

// });
// Fetching persisted conversation lists for all accounts
// We may want to fetch only the selected account's conversation list
// in the future, but this is simple for now, and want to get feedback to really confirm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we confirming?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming actual timing of real users

Difficult to gauge in dev, but benchmarks on the SDK side are good

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
components/StateHandlers/HydrationStateHandler.tsx (1)

23-25: Consider documenting the rationale for fetching all accounts

The comment suggests this is a temporary solution pending feedback. Consider documenting:

  1. Performance implications of fetching all accounts
  2. Criteria for deciding when to switch to selected account only
  3. Metrics being collected for the feedback
queries/useV3ConversationListQuery.ts (1)

106-112: Consider adding retry configuration for network resilience

The fetch operations (fetchPersistedConversationListQuery, fetchConversationListQuery, prefetchConversationListQuery) could benefit from retry configuration to handle temporary network issues.

Consider adding retry configuration to the query config:

 const v3ConversationListQueryConfig = (
   account: string,
   context: string,
   includeSync: boolean = true
 ) => ({
   queryKey: conversationListKey(account),
   queryFn: () => v3ConversationListQueryFn(account, context, includeSync),
   staleTime: 2000,
   enabled: !!account,
+  retry: 3,
+  retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
 });

Also applies to: 116-118, 122-124

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 092da29 and 4507643.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • components/StateHandlers/HydrationStateHandler.tsx (2 hunks)
  • package.json (1 hunks)
  • queries/useInboxProfileSocialsQuery.ts (2 hunks)
  • queries/useProfileSocialsQuery.ts (2 hunks)
  • queries/useV3ConversationListQuery.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • queries/useProfileSocialsQuery.ts
  • queries/useInboxProfileSocialsQuery.ts
  • package.json
🧰 Additional context used
📓 Learnings (1)
queries/useV3ConversationListQuery.ts (1)
Learnt from: alexrisch
PR: ephemeraHQ/converse-app#1313
File: queries/useV3ConversationListQuery.ts:196-268
Timestamp: 2024-12-05T18:33:24.472Z
Learning: In the TypeScript file `queries/useV3ConversationListQuery.ts`, helper functions like `updateGroupImageToConversationListQuery`, `updateGroupNameToConversationListQuery`, and `updateGroupDescriptionToConversationListQuery` are used to reduce dependency on exact types or creating objects that get passed unnecessarily, even though they internally use `updateGroupMetadataToConversationListQuery`.
🔇 Additional comments (4)
components/StateHandlers/HydrationStateHandler.tsx (2)

8-8: LGTM: New import aligns with PR objectives

The addition of fetchPersistedConversationListQuery import supports the PR's goal of fetching persisted conversations before dismissing the splash screen.


27-42: ⚠️ Potential issue

Enhance error handling for Promise.allSettled

While the implementation correctly uses Promise.allSettled for concurrent fetching, it doesn't handle rejected promises. This could lead to silent failures.

Consider this enhancement:

-      await Promise.allSettled(
+      const results = await Promise.allSettled(
         accounts.map(async (account) => {
           const accountStartTime = new Date().getTime();
           logger.debug(
             `[Hydration] Fetching persisted conversation list for ${account}`
           );
           await getXmtpClient(account);
           await fetchPersistedConversationListQuery(account);
           const accountEndTime = new Date().getTime();
           logger.debug(
             `[Hydration] Done fetching persisted conversation list for ${account} in ${
               (accountEndTime - accountStartTime) / 1000
             } seconds`
           );
         })
       );
+      const failures = results.filter(r => r.status === 'rejected');
+      if (failures.length > 0) {
+        logger.error('[Hydration] Failed to fetch some persisted conversations:', 
+          failures.map(f => (f as PromiseRejectedResult).reason));
+      }
queries/useV3ConversationListQuery.ts (2)

83-92: LGTM: Well-structured query configuration centralization

The new v3ConversationListQueryConfig function effectively centralizes the configuration, improving maintainability and reducing duplication. The staleTime of 2000ms seems reasonable for this use case.


129-132: LGTM: Consistent usage of query configuration

The modifications to invalidateGroupsConversationListQuery, getConversationListQueryData, and setConversationListQueryData maintain consistency by using the centralized configuration.

Also applies to: 140-141, 150-151

Added persistance by query
Bumped ReactQuery Versions
Added handling to fetch persisted conversations before dismissing the splash screen
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
queries/useV3ConversationListQuery.ts (1)

Line range hint 100-151: Consider adding error boundaries for query failures

While the refactoring to use centralized configuration is good, consider adding error boundaries or retry logic for network-related failures in the query functions.

Example for fetchPersistedConversationListQuery:

 export const fetchPersistedConversationListQuery = (account: string) => {
   return queryClient.fetchQuery(
     v3ConversationListQueryConfig(
       account,
       "fetchPersistedConversationListQuery",
       false
-    )
+    ),
+    {
+      retry: 2,
+      retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000)
+    }
   );
 };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4507643 and 66cea07.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • components/StateHandlers/HydrationStateHandler.tsx (2 hunks)
  • package.json (1 hunks)
  • queries/useInboxProfileSocialsQuery.ts (2 hunks)
  • queries/useProfileSocialsQuery.ts (2 hunks)
  • queries/useV3ConversationListQuery.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • queries/useProfileSocialsQuery.ts
  • queries/useInboxProfileSocialsQuery.ts
  • package.json
🧰 Additional context used
📓 Learnings (1)
queries/useV3ConversationListQuery.ts (1)
Learnt from: alexrisch
PR: ephemeraHQ/converse-app#1313
File: queries/useV3ConversationListQuery.ts:196-268
Timestamp: 2024-12-05T18:33:24.472Z
Learning: In the TypeScript file `queries/useV3ConversationListQuery.ts`, helper functions like `updateGroupImageToConversationListQuery`, `updateGroupNameToConversationListQuery`, and `updateGroupDescriptionToConversationListQuery` are used to reduce dependency on exact types or creating objects that get passed unnecessarily, even though they internally use `updateGroupMetadataToConversationListQuery`.
🔇 Additional comments (3)
components/StateHandlers/HydrationStateHandler.tsx (2)

7-8: LGTM: Clean import addition

The import of fetchPersistedConversationListQuery aligns with the PR objective to fetch persisted conversations before dismissing the splash screen.


23-42: ⚠️ Potential issue

Handle rejected promises from Promise.allSettled

While the concurrent fetching implementation is good, the code doesn't handle potential failures from Promise.allSettled. This could lead to silent failures if fetching fails for some accounts.

Consider handling the results:

-      await Promise.allSettled(
+      const results = await Promise.allSettled(
         accounts.map(async (account) => {
           const accountStartTime = new Date().getTime();
           logger.debug(
             `[Hydration] Fetching persisted conversation list for ${account}`
           );
           await getXmtpClient(account);
           await fetchPersistedConversationListQuery(account);
           const accountEndTime = new Date().getTime();
           logger.debug(
             `[Hydration] Done fetching persisted conversation list for ${account} in ${
               (accountEndTime - accountStartTime) / 1000
             } seconds`
           );
         })
       );
+      
+      // Log any failures
+      results.forEach((result, index) => {
+        if (result.status === 'rejected') {
+          logger.error(
+            `[Hydration] Failed to fetch conversations for account ${accounts[index]}:`,
+            result.reason
+          );
+        }
+      });
queries/useV3ConversationListQuery.ts (1)

83-92: LGTM: Well-structured query configuration

Good centralization of query configuration with proper defaults and type safety. The inclusion of context and includeSync parameters provides flexibility for different use cases.

@alexrisch alexrisch merged commit 0ca98a5 into release/3.0.0 Dec 11, 2024
8 checks passed
@alexrisch alexrisch deleted the ar/hydration branch December 11, 2024 16:37
technoplato pushed a commit that referenced this pull request Dec 17, 2024
Added persistance by query
Bumped ReactQuery Versions
Added handling to fetch persisted conversations before dismissing the splash screen
This was referenced Dec 19, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 30, 2024
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.

2 participants