v152 · Storage
Concurrent Writers
Launch multiple parallel readwrite transactions that each write 50 records simultaneously. After all transactions complete, read every record back and verify the count. The SQLite backend's WAL (write-ahead logging) and atomic transactions ensure no writes are lost — even under high concurrency.
The web API is identical before and after Chrome 152's SQLite migration. This demo exercises the same
IDBTransaction patterns, but Chrome 152+ uses SQLite's atomic transactions under the hood — providing better durability guarantees under concurrent load.
4
50
writers
—
writes attempted
—
writes verified
—
errors
—
Run the test first, then verify.
transaction log
code
// Open the database
const db = await new Promise((resolve, reject) => {
const req = indexedDB.open('concurrent-test', 1);
req.onupgradeneeded = e => e.target.result.createObjectStore('records', { keyPath: 'id' });
req.onsuccess = e => resolve(e.target.result);
req.onerror = reject;
});
// Launch N parallel readwrite transactions
const writers = Array.from({ length: N }, (_, w) =>
new Promise((resolve, reject) => {
const tx = db.transaction(['records'], 'readwrite');
const store = tx.objectStore('records');
// Write 50 records per transaction
for (let i = 0; i < 50; i++) {
store.put({ id: `w${w}-r${i}`, writer: w, value: Math.random() });
}
tx.oncomplete = resolve;
tx.onerror = reject;
})
);
// Wait for all to finish
await Promise.all(writers);
// Verify: count all records
const count = await new Promise(resolve => {
const tx = db.transaction(['records'], 'readonly');
tx.objectStore('records').count().onsuccess = e => resolve(e.target.result);
});