[w3c/IndexedDB] Transaction storm in idb-transaction-commit explainer sample (#245)

The sample code in [Scenario 1: Populating a database](https://andreas-butler.github.io/idb-transaction-commit/EXPLAINER#scenario-1-populating-a-database) issues a transaction for each "chunk". The problem is that all the transactions are fired simultaneously.

I suspect you want something along the lines of

```js
for (const data_chunk of data_chunks) {
  await new Promise(resolve, reject) {
    ...
    txn.onsuccess = (event) => resolve();
    txn.onerror = (event) => reject(event.target.error);
    ...
  }
}
```

This fires transactions in sequence. While both variants are technically correct, the former is a bad pattern that causes memory bloat while the requests are queued up, waiting for the transactions to commit one by one.

nits:
* `indexedDB.open('myDatabase')`
* `db.transaction(['myStore'], ....)`

/cc @andreas-butler 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/245

Received on Wednesday, 17 October 2018 00:56:14 UTC