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] Init Regression #26

Merged
merged 1 commit into from
Nov 6, 2023
Merged

[Fix] Init Regression #26

merged 1 commit into from
Nov 6, 2023

Conversation

stevensJourney
Copy link
Collaborator

@stevensJourney stevensJourney commented Nov 6, 2023

Description

The work from #25 introduced waitForReady on the PowerSyncDatabase client. This function should resolve once the client has been fully initialised.

The waitForReady method was previously responsible for setting the AbstractPowerSyncDatabase.ready member, but the initialized listener would only be registered once waitForReady had been called. If the init function had been called and completed before any waitForReady calls were made: the executed waitForReady function would never resolve as the initialized event would not be triggered again (init was already completed).

This issue was initially not detected in testing as (a logged in) test app contains watched queries which triggered waitForReady and correctly configured the initialized listener before init had completed. This bug is however relevant when completing the signin flow as no queries are awaited before the init call is made.

Fix

The API now follows the Flutter SDK by automatically calling the initialize method when the client is constructed. The init method now also follows the FlutterSDK by using waitForReady to allow catching any errors during initialisation and await intitialzation, waitForReady is still used throughout the implementation as it's name is more indicative of its function.

@stevensJourney stevensJourney marked this pull request as ready for review November 6, 2023 14:42
@stevensJourney stevensJourney merged commit 36a9d21 into main Nov 6, 2023
2 checks passed
@stevensJourney stevensJourney deleted the test_init branch November 6, 2023 15:07
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.

3 participants