Reputation: 21
I'm using dexiejs to insert data in a Indexdb table(about 10k records).
After the rw transaction is completed, which I am checking with the following methods:
try {
await QDB.transaction("rw", table1, table1, async tx => {
//ALSO CHECK TX
tx.on("complete", () => console.log("COMPLETED"));
//here goes the bulkadd code ...
});
console.log("COMPLETED");
} catch (e) {
console.log(e);
}
So after the above is completed, I then try to execute another transaction that modifies only certain records, but it takes about 20s before this last transaction even starts.
I even traced the whole process inside the chrome profiler and the browser seems relatively at ease for those 20s before the last transaction starts.
Why is that?
Thanks in advance
Upvotes: 0
Views: 195
Reputation: 21
copying comment:
I solved it by using only one transaction. The source of the problem though was that I was using nested async function with await Dexie.waitFor(). I think that using nested promises inside waitFor causes the inner promises to be called with some delay
Upvotes: 1
Reputation: 5646
How do you detect when the second transaction "starts" - is it when your first operation in it is resolved?
Anyhow, there might be several reasons for this. One is if you have another readonly transaction going on that blocks the next transaction from finishing. Another, I suppose, could be that the background thread that handles data processing for IndexedDB may be busy with cleanup work after a transaction has finished. If that would be the case I suppose it would not happen after every run though but more sporadically.
Upvotes: 0