From 4e7ec7cad02ff2053ab010cf814db11bea912b67 Mon Sep 17 00:00:00 2001 From: bangjiehan <bangjiehan@gmail.com> Date: Thu, 13 Mar 2025 11:05:51 +0800 Subject: [PATCH 1/3] Fix typo --- 6-data-storage/03-indexeddb/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6-data-storage/03-indexeddb/article.md b/6-data-storage/03-indexeddb/article.md index 43344e487a..2d64fade18 100644 --- a/6-data-storage/03-indexeddb/article.md +++ b/6-data-storage/03-indexeddb/article.md @@ -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. From f5ca5b159ae1a9cec89bba07f0bbf32d29296983 Mon Sep 17 00:00:00 2001 From: bangjiehan <bangjiehan@gmail.com> Date: Thu, 13 Mar 2025 11:46:42 +0800 Subject: [PATCH 2/3] Fix typo --- 6-data-storage/03-indexeddb/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6-data-storage/03-indexeddb/article.md b/6-data-storage/03-indexeddb/article.md index 2d64fade18..64bc1d8738 100644 --- a/6-data-storage/03-indexeddb/article.md +++ b/6-data-storage/03-indexeddb/article.md @@ -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. Authors of IndexedDB spec believe that transactions should be short-lived. Mostly for performance reasons. From 50351c03113e48ff79c53f855134efc7b016db3a Mon Sep 17 00:00:00 2001 From: bangjiehan <bangjiehan@gmail.com> Date: Thu, 13 Mar 2025 16:00:51 +0800 Subject: [PATCH 3/3] Fix typo --- 6-data-storage/03-indexeddb/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6-data-storage/03-indexeddb/article.md b/6-data-storage/03-indexeddb/article.md index 64bc1d8738..8710daec00 100644 --- a/6-data-storage/03-indexeddb/article.md +++ b/6-data-storage/03-indexeddb/article.md @@ -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. For a promise wrapper and `async/await` the situation is the same.