You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.
All of the promises in the transaction's extend lifetime promises fulfill
There are still outstanding requests
And also:
When those outstanding requests complete, new requests are made
The plausible behaviors I can think of are:
Once all of the promises in the transaction's extend lifetime promises fulfill, the state transitions back to "inactive" (or "active" if we happen to be in an IDB event dispatch!), and the previous lifetime rules resume. It can be kicked back to "waiting" by further waitUntil() calls.
We do transition to "committing"; any responses that come back after this point fire the usual events/resolutions, but new requests throw "InvalidStateError".
The former feels more natural to me, but the second makes sense if you consider using waitUntil() to build explicitly committing transactions:
asyncfunctiondoStuff(db,url){consttx=db.transaction('store','readwrite');conststore=tx.objectStore('store');letrecord=awaitstore.get(url);if(!record){constp=fetch(url);// Pretend this yields a cloneable thingtx.waitUntil(p);constr=awaitp;// NOTE: if waitUntil(x) returns x, then above can be just:// const r = await tx.waitUntil(fetch(url));// NOTE: extend lifetime promises have fulfilled, but don't want to commit yet!store.put(r,url);}returnrecord;}
If you don't transition back to "active" then you must write the waitUntil() so that it encompasses the entire promise chain. If you do transition back to "active" then it is possible to just waitUntil() a non-IDB operation to "bring it into the fold".
Note that the or "active" if we happen to be in an IDB event dispatch clause needs handling even in the case where there are no more outstanding requests. An important case to get right: the transaction is waiting on one of its own requests. The timing of the dispatch vs. resolution is also critical there - don't want to try and commit too early, nor forget to commit.
Need to specify the behavior for:
And also:
The plausible behaviors I can think of are:
waitUntil()
calls."InvalidStateError"
.The former feels more natural to me, but the second makes sense if you consider using
waitUntil()
to build explicitly committing transactions:(But I still lean towards the former)
The text was updated successfully, but these errors were encountered: