BroadcastChannel and Web Locks API vs IndexedDB Transactions and Storage Quotas
IndexedDB locks object stores per transaction, whereas Web Locks and BroadcastChannel coordinate multi-tab state explicitly.
Structured Comparison Matrix
| Dimension | BroadcastChannel and Web Locks API | IndexedDB Transactions and Storage Quotas |
|---|---|---|
| Mental Model | Origin-scoped pub/sub messaging and async mutual-exclusion locks coordinated by the browser process across tabs, iframes, and workers. | Transactional client-side B-tree object store whose transactions auto-commit on microtask drain and whose storage limits depend on origin-wide disk quotas. |
| Maturity & Domain | Baseline · Widely · Web APIs Chrome 54+ (BroadcastChannel), 69+ (Web Locks) · Firefox 38+ (BroadcastChannel), 96+ (Web Locks) · Safari 15.4+ (BroadcastChannel & Web Locks) | Baseline · Widely · Web APIs Chrome 24+ · Firefox 16+ · Safari 10+ |
| Prerequisites | ||
| When Not to Use | When not to use BroadcastChannel: Cross-origin iframes cannot share a BroadcastChannel; use window.postMessage() with explicit targetOrigin checks instead. | 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. |
Engine Mechanics & Trade-Offs
The browser process maintains an origin-partitioned pub/sub bus and an async mutex queue that automatically releases locks if a renderer process crashes or closes.
Key Pitfalls: Holding a lock forever for leader election: If a leader tab sleeps in bfcache while holding a lock, it can stall other tabs unless you release locks on pagehide or use AbortController. Nested lock deadlocks: Acquiring lock A then B in one tab and B then A in another hangs both queues permanently; pass an AbortSignal ti
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
Seen in Architecture Autopsies
A user edits a document offline on a train and silently overwrites a teammate's merged changes upon reconnection.
Users opening 8 tabs exhaust realtime gateway sockets and freeze the main thread during 400 msg/s bursts.