IndexedDB Transactions and Storage Quotas vs Origin Private File System (OPFS)
OPFS provides raw byte-level file handles without structured-clone or transaction overhead.
Structured Comparison Matrix
| Dimension | IndexedDB Transactions and Storage Quotas | Origin Private File System (OPFS) |
|---|---|---|
| Mental Model | Transactional client-side B-tree object store whose transactions auto-commit on microtask drain and whose storage limits depend on origin-wide disk quotas. | Origin-sandboxed virtual file system backed by raw OS files, offering synchronous in-place byte-range I/O inside Dedicated Workers. |
| Maturity & Domain | Baseline · Widely · Web APIs Chrome 24+ · Firefox 16+ · Safari 10+ | Baseline · Widely · Web APIs Chrome 86+ (SyncAccessHandle 102+) · Firefox 111+ · Safari 15.2+ |
| Prerequisites | ||
| When Not to Use | When not to use IndexedDB: For sequential binary file streaming, SQLite page files, or append-only logs, use OPFS instead of serializing chunks into B-tree records; for multi-tab mutexes or offline conflict resolution, pair it with BroadcastChannel & Web Locks and Local-First Sync & CRDTs. | When not to use OPFS: For small key-value settings or indexed JSON queries, IndexedDB avoids manual byte-offset management and exclusive file locking. |
Engine Mechanics & Trade-Offs
IndexedDB serializes overlapping readwrite transactions per object store and auto-commits any transaction left idle across an async await boundary.
Key Pitfalls: Awaiting non-IDB promises inside a transaction: await fetch() or await new Promise(setTimeout) closes the transaction and throws TransactionInactiveError on the next write. Large structuredClone payloads on the main thread: Writing 50 MB blobs in one store.put() stalls the UI thread; run heavy writes in a Dedicated Web
OPFS maps directly to sandboxed OS file descriptors, allowing Dedicated Workers to perform synchronous in-place read/write syscalls via FileSystemSyncAccessHandle.
Key Pitfalls: Multi-tab lock contention: createSyncAccessHandle() throws NoModificationAllowedError if another tab holds the file lock; wrap access in navigator.locks.request(). Forgetting flush() and close(): Buffered writes may vanish on sudden tab termination, and unclosed handles block future workers from opening the file.
Seen in Architecture Autopsies
A user edits a document offline on a train and silently overwrites a teammate's merged changes upon reconnection.
Rich spreadsheet and graph app drops to 4 FPS during 100k-row sorts until state and OPFS move to a Worker.