Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 6-data-storage/03-indexeddb/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ The short answer is: we don't.

In the next version 3.0 of the specification, there will probably be a manual way to finish the transaction, but right now in 2.0 there isn't.

**When all transaction requests are finished, and the [microtasks queue](info:microtask-queue) is empty, it is committed automatically.**
**When all transaction requests are finished, and the [macrotasks queue (event queue)](info:event-loop) is empty, it is committed automatically.**

Usually, we can assume that a transaction commits when all its requests are complete, and the current code finishes.

Expand All @@ -367,7 +367,7 @@ request1.onsuccess = function() {
};
```

That's because `fetch` is an asynchronous operation, a macrotask. Transactions are closed before the browser starts doing macrotasks.
That's because `fetch` is an asynchronous operation, a microtask. Transactions are closed before the browser starts doing microtasks.
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is incorrect. fetch is a macrotask, not a microtask. The original text was correct - fetch creates a macrotask and transactions are closed before macrotasks execute.

Suggested change
That's because `fetch` is an asynchronous operation, a microtask. Transactions are closed before the browser starts doing microtasks.
That's because `fetch` is an asynchronous operation, a macrotask. Transactions are closed before the browser starts doing macrotasks.

Copilot uses AI. Check for mistakes.

Authors of IndexedDB spec believe that transactions should be short-lived. Mostly for performance reasons.

Expand Down Expand Up @@ -774,7 +774,7 @@ window.addEventListener('unhandledrejection', event => {

### "Inactive transaction" pitfall

As we already know, a transaction auto-commits as soon as the browser is done with the current code and microtasks. So if we put a *macrotask* like `fetch` in the middle of a transaction, then the transaction won't wait for it to finish. It just auto-commits. So the next request in it would fail.
As we already know, a transaction auto-commits as soon as the browser is done with the current code and macrotasks. So if we put a *microtask* like `fetch` in the middle of a transaction, then the transaction won't wait for it to finish. It just auto-commits. So the next request in it would fail.
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces an error. fetch is a macrotask, not a microtask. The sentence should read 'So if we put a macrotask like fetch' to be technically accurate.

Suggested change
As we already know, a transaction auto-commits as soon as the browser is done with the current code and macrotasks. So if we put a *microtask* like `fetch` in the middle of a transaction, then the transaction won't wait for it to finish. It just auto-commits. So the next request in it would fail.
As we already know, a transaction auto-commits as soon as the browser is done with the current code and macrotasks. So if we put a *macrotask* like `fetch` in the middle of a transaction, then the transaction won't wait for it to finish. It just auto-commits. So the next request in it would fail.

Copilot uses AI. Check for mistakes.

For a promise wrapper and `async/await` the situation is the same.

Expand Down