Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix typo#3823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
bangjiehan wants to merge3 commits intojavascript-tutorial:master
base:master
Choose a base branch
Loading
frombangjiehan:patch-2
Open
Changes fromall 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 deletions6-data-storage/03-indexeddb/article.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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, amacrotask. Transactions are closed before the browser starts doingmacrotasks.
That's because `fetch` is an asynchronous operation, amicrotask. Transactions are closed before the browser starts doingmicrotasks.

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

Expand DownExpand 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 andmicrotasks. 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 andmacrotasks. 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.

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp