Synchronous JS build #200
Replies: 1 comment 6 replies
-
I think a patch or fork is the way to go. It's not something I'm interested in doing myself (unless under paid contract or sponsorship), but I'm happy to provide advice both to help you get started and along the way in case you run into problems. Are you planning to write your own synchronous VFS or use one of the examples? If you're going to use an example VFS, I think that only MemoryVFS and AccessHandlePoolVFS will work. OPFSCoopSyncVFS is a synchronous VFS so it works with a synchronous WebAssembly build, but it also depends on the asynchronous JavaScript API wrappers that you want to change. That's what this line does: Lines 731 to 732 in f5092b5 This lets wa-sqlite wait for asynchronous things to happen outside SQLite WebAssembly so the build can be synchronous. Right now OPFSCoopSyncVFS is the only example VFS that uses this mechanism. If you're not using it then I think your synchronous version could look like this: return function(stmt) {
verifyStatement(stmt);
console.assert(!Module.retryOps.length, 'retry operations ignored');
const rc = f(stmt);
return check(fname, rc, mapStmtToDB.get(stmt), [SQLite.SQLITE_ROW, SQLite.SQLITE_DONE]);
}; |
Beta Was this translation helpful? Give feedback.
-
First of all, thanks for the continuous great work that has gone into this project. I'm about to switch to wa-sqlite for LiveStore given a few limitations I've been facing with the "official" sqlite-wasm project.
In LiveStore I'm running two SQLite instances. (1) in-memory on the main thread and (2) a OPFS-persisted SQLite instance.
For (1) (and possibly for (2)) I'll need a synchronous build of SQLite. It seems like there is already a synchronous WASM built but the JS functions are using
async
/await
:wa-sqlite/src/sqlite-api.js
Lines 728 to 736 in f5092b5
Would you recommend me working with a local patch to remove the
async
code from thesqlite-api.js
(would this even work?) or would you be open to also providing a synchronous API version?Thanks a lot in advance! 🙏
Beta Was this translation helpful? Give feedback.
All reactions