Skip to content

Fix libsqlSyncInterval parameter handling in openSync function#285

Merged
ospfranco merged 1 commit into
OP-Engineering:mainfrom
twelvearrays:twelvearrays-fix/libsqlSyncInterval_value_undefined
Jun 12, 2025
Merged

Fix libsqlSyncInterval parameter handling in openSync function#285
ospfranco merged 1 commit into
OP-Engineering:mainfrom
twelvearrays:twelvearrays-fix/libsqlSyncInterval_value_undefined

Conversation

@twelvearrays
Copy link
Copy Markdown
Contributor

Fixed a bug in cpp/bindings.cpp where the code was checking for the property "libsqlSyncInterval" but then trying to read "syncInterval" instead. This mismatch caused the native code to attempt to read an undefined property, resulting in the JSI error.

This bug was likely introduced during the rename from syncInterval to libsqlSyncInterval in PR #272, where this specific line wasn't updated correctly. The fix ensures that the libsqlSyncInterval parameter is properly passed through to the native libsql configuration.

@ospfranco ospfranco merged commit 55491b9 into OP-Engineering:main Jun 12, 2025
8 checks passed
@ospfranco
Copy link
Copy Markdown
Contributor

thanks a lot!

@twelvearrays
Copy link
Copy Markdown
Contributor Author

The interval is now not throwing an error but it seems like it has no effect on syncing.

For example, with the following code:

sqlite = openSync({ name: DB_FILENAME, location: "default", url: databaseUrl, authToken: authToken, libsqlSyncInterval: SYNC_INTERVAL, // <-- 5 libsqlOffline: true, // keep offline mode – remote writes still pushed by libSQL });

I would expect that we would write to our local libsql database and then every 5 seconds sync to the remote database hosted via Turso.

Is my thinking correct?

Also, always happy to help with a PR.

@ospfranco
Copy link
Copy Markdown
Contributor

No idea about the functioning of libsql, you have to ask turso. @haaawk @levydsa

@leonfs
Copy link
Copy Markdown

leonfs commented Jul 25, 2025

The interval is now not throwing an error but it seems like it has no effect on syncing.

For example, with the following code:

sqlite = openSync({ name: DB_FILENAME, location: "default", url: databaseUrl, authToken: authToken, libsqlSyncInterval: SYNC_INTERVAL, // <-- 5 libsqlOffline: true, // keep offline mode – remote writes still pushed by libSQL });

I would expect that we would write to our local libsql database and then every 5 seconds sync to the remote database hosted via Turso.

Is my thinking correct?

Also, always happy to help with a PR.

I would expect the same. When offline is set to true the automatic synching doesn't happen. It does when the offline param is false.

Did you find a solution for that @twelvearrays ?

@twelvearrays
Copy link
Copy Markdown
Contributor Author

I believe the functionality is the following:

libsqlOffline: true -> It does not use the sync internal. You have to manually sync.
libsqlOffline: false -> this uses a embedded replica, ie remote database, to sync on the libsqlSyncInterval if set.

At least that is what I have figured out. I have moved to manual sync on writes.

@leonfs
Copy link
Copy Markdown

leonfs commented Jul 28, 2025

thanks 🙏 @twelvearrays - yes, I came to the same conclusion: manual syncing is the way.

subtleGradient pushed a commit to effect-native/op-sqlite that referenced this pull request Sep 12, 2025
…fix/libsqlSyncInterval_value_undefined

Fix libsqlSyncInterval parameter handling in openSync function
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