Skip to main content

WASQLiteVFS

List of currently tested virtual filesystems

Enumeration Members​

Enumeration MemberValueDescription
AccessHandlePoolVFS"AccessHandlePoolVFS"-
IDBBatchAtomicVFS"IDBBatchAtomicVFS"-
InMemoryVfs"InMemoryVFS"A virtual file system storing data in-memory only, without persistence. This file system can be used in three configurations: 1. In shared workers (the default when available): All tabs share the same in-memory database, which is cleared once the last tab is closed. 2. In dedicated workers (used when enableMultiTabs is disabled). Each tab has its own in-memory database cleared when the tab is closed. Queries are offloaded to a dedicated worker. 3. In the context of the tab itself (used when both enableMultiTabs and useWebWorker are disabled). The per-tab database is hosted in the tab itself, and queries run synchronously. This is a lot faster than any other single-threadedVFS, but can block JavaScript for computationally-intensive queries. This VFS primarily intended for development, but it also useful for online-first deployments not syncing large amounts of data, as it is quicker to start up.
OPFSCoopSyncVFS"OPFSCoopSyncVFS"-
OPFSWriteAheadVFS"OPFSWriteAheadVFS"-
SimpleOpfsVFS"SimpleOpfsVFS"A simple OPFS-based virtual file system. This VFS uses a very simple internal design: Instead of opening files on demand (or with a prior pool), it uses the fact that that a SQLite database only consists of two files: The main database and a journal for recovery. These two file handles are pre-opened before the database is used, allowing all IO to be synchronous and to go directly to those files. It is worth noting that this design has fundamental drawbacks: It doesn't support ATTACHing additional databases, and temporary data (e.g. for materialized CTEs) is always stored in memory. This is not relevant for most setups though, and not supporting this is what enables the simple design. Synchronous file handles in OPFS are only available in dedicated workers, and two tabs can't open the same file at the same time. To enable multi-tab support, this VFS comes in three possible configurations, the PowerSync SDK selects the best one based on browser features: 1. Shared workers: While we need dedicated workers to access files synchronously, the web standard allows shared workers to spawn their own dedicated workers. This is not supported by all browsers, but highly efficient option when available as we don't need to rely on navigator locks. 2. readwrite-unsafe: On Chromium browsers, this flag allows multiple tabs to access the same files (the PowerSync SDK additionally uses navigator locks to avoid corruption from concurrent writes). 3. Close and open fallback: On other browsers, file handles are kept open until another tab signals that it needs access to them. At that point, queued local transactions are awaited before closing the file handles. At the next database query, the same signal is sent to the other tab before re-opening files locally.