Rust-based Sync Client (SyncClientImplementation.RUST) fails to sync changes made offline
We are using powersync with a react native app. We have a postgres database. A month ago (~July 1st) we turned on the experimental rust-based sync client.
powerSyncDb
/*** ADDED THESE 3 LINES ***/
.connect(connector, {
clientImplementation: SyncClientImplementation.RUST,
})
.then(() => {
powerSyncDb.init();
});
We soon noticed that syncing was failing. Specifically, this occured when:
- we turned off cell/wifi
- while offline, modified data on the app (modifying an existing row)
- turned wifi back on so that sync would commence.
We display the powersync status in the app (reading from useStatus().hasSynced), and it would alternate between showing 'syncing...' (hasSynced = false) and then briefly showing up to date (hasSynced = true), before going back to syncing. Our postgres DB never received the updated data. The issue did not surface if you never turned wifi off/on; if you made changes all while online, those seemed to sync.
On July 3rd we identified the issue and removed the rust-client flag, which resolved the issue. I recognize that this is an experimental feature, but wanted to flag so that the folks working on this feature are aware. Apologies for not filing an issue sooner - was on vacation for a bit and forgot. We did love how fast the rust sync engine was when it worked, was so are very excited for it's potential.
Thank you!
"@powersync/common": "^1.32.0",
"@powersync/kysely-driver": "^1.2.0",
"@powersync/op-sqlite": "^0.7.0",
"@powersync/react": "^1.5.3",
"@powersync/react-native": "^1.22.0",
"@powersync/tanstack-react-query": "^0.0.26",
Thank you for the report! hasSynced having wrong values while offline is a known issue that has since been fixed (but that fix has not made it into the JS SDKs yet). We'll also take a look at the missing local writes!
Thank you! And just to be clear in case it wasn't:
- the cycling
hasSyncedvalues showed up after turning on connectivity. - the local writes were saved, just not synced to our cloud db
I couldn't reproduce the issue by following the steps you've shared in our todolist demo (I did use the unreleased core extension update though). It is possible that we've fixed this in the meantime with a refactor of the connectivity logic.
Since it sounds like you can reproduce this reliably, I'll let you know when these changes have been released. Then it may be worth taking another look, if you still reproduce it afterwards we may need more information.