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: missing userSyncStatus db table upon clean install #2001

Merged
merged 3 commits into from
Mar 10, 2023

Conversation

santhoshvai
Copy link
Member

@santhoshvai santhoshvai commented Mar 10, 2023

🎯 Goal

While doing a clean install with offline support, or changing from enableOfflineSupport={false} to true on the sample with no previous db table. We get the following error:

Error: [react-native-quick-sqlite] SQL execution error: no such table: userSyncStatus

This PR aims to fix the issue.

🛠 Implementation details

A race condition happens such that the userSyncStatus table is accessed before it is created. In this PR, I added a state to wait till DB is initialized.

🎨 UI Changes

NA

🧪 Testing

  1. Remove the current sample app on iOS simulator
  2. Set enableOfflineSupport to false
  3. Open app
  4. Force closes the app
  5. Set enableOfflineSupport to true
  6. Open the app again
  7. The error shared above should not happen

☑️ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

QuickSqliteClient.initializeDatabase();
DBSyncManager.init(client as unknown as StreamChat);
}
}, [client?.user?.id]);
Copy link
Contributor

Choose a reason for hiding this comment

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

the fact that we missed enableOfflineSupport is also a red flag

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@santhoshvai santhoshvai changed the title fix: missing userSyncStatus db upon clean install fix: missing userSyncStatus db table upon clean install Mar 10, 2023
@santhoshvai santhoshvai merged commit 36eb866 into develop Mar 10, 2023
@santhoshvai santhoshvai deleted the db-race-condition branch March 10, 2023 12:02
@github-actions github-actions bot mentioned this pull request Mar 16, 2023
@stream-ci-bot
Copy link
Contributor

🎉 This PR is included in version 5.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants