Skip to content

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Apr 15, 2025

PowerSyncDatabaseImpl.connect used to call waitReady() inside of mutex.withLock. That's unfortunate, because initialize also acquires the mutex in updateSchemaInternal. So, when calling connect() immediately after creating a database, there's a potential for a deadlock. The mutex must only be acquired after waiting for the database to be initialized.

To validate the fix, I've migrated the sync tests to stop calling connectInternal and instead use the public connect method. This requires customizing the HTTP client engine passed to the sync engine, for which I've created an (internal) method next to the PowerSyncDatabase factory method.

Closes #169.

@simolus3 simolus3 requested a review from stevensJourney April 15, 2025 12:43
@simolus3 simolus3 merged commit 568c3b1 into main Apr 15, 2025
3 checks passed
@simolus3 simolus3 deleted the fix-connect-on-open branch April 15, 2025 12:52
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.

No data when updated to BETA29 (Android)
2 participants