Repository navigation
IDB VFSs: add getIDBFactory and prefix options - #387
Open
lalexdotcom wants to merge 1 commit into
Open
lalexdotcom wants to merge 1 commit into
lalexdotcom wants to merge 1 commit into
Conversation
Contributor
Author
|
One more note on If you'd like, I can add an |
The same options rhashimoto#380 gave the OPFS VFSs. getIDBFactory lets an app keep a database in another IDBFactory than the global one, such as the indexedDB of a Storage Bucket, which has its own persistence and durability settings. prefix keeps the Web Lock and BroadcastChannel names of a file apart from those of a file of the same name in another factory. The lock names of IDBBatchAtomicVFS are built by WebLocksMixin, so the prefix option lives there and also applies to the other VFSs that use the mixin: OPFSAdaptiveVFS, OPFSAnyContextVFS and OPFSPermutedVFS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lalexdotcom
force-pushed
the
idb-factory-prefix
branch
from
October 25, 2026 16:21
7805bb2 to
516b308
Compare
Contributor
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the follow-up offered in #380: the same options for
IDBBatchAtomicVFSandIDBMirrorVFS, following that PR's API and test layout.Why
Both VFSs open their database with the global
indexedDB. A Storage Bucket has its ownIDBFactory(bucket.indexedDB) and its own persistence and durability settings. So an app could keep the databases it can't afford to lose in a bucket opened withpersisted: true, and leave the ones it can rebuild in the default bucket, where the browser may evict them.The change
getIDBFactoryreturns theIDBFactorythe VFS opens its database with. By default it returnsindexedDB. It may return the factory itself or a promise of one.prefixgoes in front of the Web Lock and BroadcastChannel names the VFS derives from its file names, as in OPFS VFSs: add getRoot and lockPrefix options #380. By default it is empty, so nothing changes.this.options, which holds the defaults.IDBMirrorVFSnow has anoptionsfield and stops ignoring itsoptionsargument.IDBBatchAtomicVFSkeepsidbName.IDBBatchAtomicVFSgets its locks fromWebLocksMixin, soprefixis an option of the mixin, next tolockPolicyandlockTimeout. That is why this PR changes two VFSs at once, and also why the option applies to the other VFSs that use the mixin:OPFSAdaptiveVFS,OPFSAnyContextVFSandOPFSPermutedVFS. If you'd rather keep it to the IndexedDB VFSs, I can change that.In
IDBMirrorVFSthe prefix is also taken into account where#getOldestTxInUse()reads the transaction locks back.The tests
test/vfs_idb_factory.jsruns for both VFSs, on the model ofvfs_root.js. A connection whosegetIDBFactoryreturns a Storage Bucket's factory must:A
getIDBFactorythat rejects must make the open fail with its error. New-customFactoryconfigurations also runvfs_xAccess,vfs_xOpen,vfs_xClose,vfs_xReadandvfs_xWritethrough a bucket, and the bucket is deleted on reset.Storage Buckets exist only in Chromium. Elsewhere, the bucket tests are pending and only the rejection test runs. On
master, all four tests fail in Chrome for both VFSs. With the prefix emptied and the factory used, the lock test still fails for both VFSs, and the separation test also fails forIDBMirrorVFS, whose channels would otherwise be shared.Conflicts with my other open PRs
#385 adds an import to
test/IDBMirrorVFS.test.jsat the same place as this PR. That is the only conflict.masterand keep both imports.masterthe same way.This PR doesn't conflict with #381, #382, #384 or #386.
Checklist
non-exclusive, royalty-free, irrevocable copyright license to reproduce, prepare
derivative works of, publicly display, sublicense, and distribute this
Contribution and such derivative works.
Contribution contains no content requiring a license from any third party.