diff --git a/src/adapters/IDB.js b/src/adapters/IDB.js index 6ba9e2d91..3f13f8a38 100644 --- a/src/adapters/IDB.js +++ b/src/adapters/IDB.js @@ -534,7 +534,19 @@ export default class IDB extends BaseAdapter { async loadDump(records) { try { await this.execute(transaction => { - records.forEach(record => transaction.update(record)); + // Since the put operations are asynchronous, we chain + // them together. The last one will be waited for the + // `transaction.oncomplete` callback. + let i = 0; + putNext(); + + function putNext() { + if (i == records.length) { + return; + } + transaction.update(records[i]).onsuccess = putNext; + ++i; + } }); const previousLastModified = await this.getLastModified(); const lastModified = Math.max( @@ -567,7 +579,7 @@ function transactionProxy(adapter, store, preloaded = []) { }, update(record) { - store.put({ ...record, _cid }); + return store.put({ ...record, _cid }); }, delete(id) {