This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 15234 - Throw if IDBTransaction.objectStore() or IDBObjectStore.index() called after transaction finished
Summary: Throw if IDBTransaction.objectStore() or IDBObjectStore.index() called after ...
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Indexed Database API (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-16 18:18 UTC by Joshua Bell
Modified: 2011-12-27 22:46 UTC (History)
4 users (show)

See Also:


Attachments

Description Joshua Bell 2011-12-16 18:18:46 UTC
The spec currently requires that IDBTransaction.objectStore() and IDBObjectStore.index() are callable after the containing transaction has finished. Since the "child" objects (IDBObjectStore and IDBIndex, respectively) contain references to the parent object, this complicates lifecycle management of these objects for implementations.

The implementation requirements could be simplified by specifying that these methods throw InvalidStateError once the transaction is finished. Alternately, the spec could be to throw TransactionInactiveError if the transaction is not active, much like the get() methods.
Comment 1 Israel Hilerio [MSFT] 2011-12-17 00:26:32 UTC
Per email thread discussion, we should throw InvalidStateError for both of the APIs below.
Comment 2 Eliot Graff 2011-12-27 21:35:52 UTC
Each method already currently has the following exception and description:

**InvalidStateError	

**Occurs if a request is made on a source object that has been deleted or removed.


Please let me know if I am misreading this and you're asking for something else.

Thanks,

Eliot
Comment 3 Joshua Bell 2011-12-27 22:12:26 UTC
It's not clear that clause covers the case this issue is discussing. Here's a snippet:

var trans = db.transaction("store");
var store = trans.objectStore("store");
// do something useful with store
trans.oncomplete = function() {
  var store = trans.objectStore("store");
  // this issue is requesting that the above line should throw
};

In this case, it does not seem that the phrase "a source object that has been deleted or removed" applies.
Comment 4 Eliot Graff 2011-12-27 22:16:06 UTC
How _would_ you phrase it to cover this? I am happy to make the change in the spec.
Comment 5 Joshua Bell 2011-12-27 22:28:12 UTC
The trivial change would be:

For IDBTransaction.objectStore(): "Occurs if a request is made on a source object that has been deleted or removed, or if the transaction has finished."

For IDBObjectStore.index(): "Occurs if a request is made on a source object that has been deleted or removed, or if the transaction the object store belongs to has finished."

I assume the "deleted or removed" phrasing - used globally in the spec - applies to cases where the IDBDatabase has been deleted or the IDBObjectStore has been deleted within a VERSION_CHANGE transaction.
Comment 6 Eliot Graff 2011-12-27 22:46:25 UTC
Changes from comment 5 are in the Editor's draft.

Thanks for your help, Joshua. Have a happy new year.

Eliot