If this method is called on IDBDatabase object for which a "versionchange" transaction is still running, a InvalidStateError exception must be thrown.
Thank you Joshua, probably that was the issue.Later I expect Chrome to implement callback onupgradeneeded when opening the DB (as Firefox does already) :request.onupgradeneeded = function(e) {[...]myDB.setVersion(db);}request.onsuccess = function(e) {[...]doStuff();
I think this makes thing more clear. I don't need to add the code you mentionned like below in this case, right ?var trans = req.result;trans.oncomplete = doStuff;
On Saturday, August 4, 2012 12:57:00 PM UTC+3, Mathieu D wrote:Sometimes an error occur when I want to create a transaction: InvalidStateError: DOM IDBDatabase Exception 11A code sample would simply be:var trans = db.transaction("myTest", "readwrite");All I have to do is restart the browser and the application would execute fine again.But still it is quite annoying for my users to see these pop-ups that an error occured and that they should restart their browser every time that happens ...Chrome version is 21.0.1180.60 m
--To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-html5/-/_AxhJRxEJAIJ.
You received this message because you are subscribed to the Google Groups "Chromium HTML5" group.
To post to this group, send email to chromiu...@chromium.org.
To unsubscribe from this group, send email to chromium-html...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-html5/?hl=en.
On Mon, Aug 6, 2012 at 2:14 PM, Mathieu D <mett...@gmail.com> wrote:Thank you Joshua, probably that was the issue.Later I expect Chrome to implement callback onupgradeneeded when opening the DB (as Firefox does already) :request.onupgradeneeded = function(e) {[...]myDB.setVersion(db);}
On Mon, Aug 6, 2012 at 2:48 PM, Joshua Bell <jsb...@chromium.org> wrote:On Mon, Aug 6, 2012 at 2:14 PM, Mathieu D <mett...@gmail.com> wrote:Thank you Joshua, probably that was the issue.Later I expect Chrome to implement callback onupgradeneeded when opening the DB (as Firefox does already) :request.onupgradeneeded = function(e) {[...]myDB.setVersion(db);}Just to be clear: you don't need to call setVersion() in the upgradeneeded event handler; when you call db.open(name, version) it starts a version change transaction for you if necessary before it calls the upgradeneeded handler.
On Monday, August 6, 2012 10:50:05 PM UTC+2, Joshua Bell wrote:
On Mon, Aug 6, 2012 at 2:48 PM, Joshua Bell <jsb...@chromium.org> wrote:On Mon, Aug 6, 2012 at 2:14 PM, Mathieu D <mett...@gmail.com> wrote:Thank you Joshua, probably that was the issue.Later I expect Chrome to implement callback onupgradeneeded when opening the DB (as Firefox does already) :request.onupgradeneeded = function(e) {[...]myDB.setVersion(db);}Just to be clear: you don't need to call setVersion() in the upgradeneeded event handler; when you call db.open(name, version) it starts a version change transaction for you if necessary before it calls the upgradeneeded handler.Hi, I'm also having the error 11 issue. However mine seems to be different, here's the relevant code:
function initDB() {var dbRequest = window.indexedDB.open(DB_NAME, DB_VERSION);dbRequest.onerror = function () {alternativeStart();};dbRequest.onsuccess = dbSuccess;dbRequest.onupgradeneeded = verChangeSuccess;
}function dbSuccess(evt){db = evt.target.result;if (db.setVersion) {if (db.version != DB_VERSION) {dbOldVersion = parseInt(db.version) ;var verRequest = db.setVersion(DB_VERSION);verRequest.onsuccess = verChangeSuccess;verRequest.onerror = function () { console.log("Error creating version change transaction");
alternativeStart();
};}else if (db.version == DB_VERSION) {dbActive = true;start();}}else {dbActive=true;start();}}For me the previous db.version equals the new DB_VERSION, so I presume no new version changed transactionis created.
It's quite unreal how much boilerblate code there is to get going.
The error messages are not very explanatory.Is it possible to query the db to ask if there are any version changed transactions open? That would be good.If there aren't any open, then this isn't the problem.. what else could it be?These guys had a similar problem : https://github.com/daleharvey/pouchdb/issues/126but luckily it magically disappeared for them when they cleared out the db. I have a objectstore clearfunction, but it didn't work for me. It's a pity the API doesn't come with a reset database (would be great for testing).I'm at quite a loss how to proceed. TIA.
Dan
--
You received this message because you are subscribed to the Google Groups "Chromium HTML5" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-html5/-/172ptoxlJR0J.
It's quite unreal how much boilerblate code there is to get going.
The error messages are not very explanatory.
Is it possible to query the db to ask if there are any version changed transactions open? That would be good.
If there aren't any open, then this isn't the problem.. what else could it be?
These guys had a similar problem : https://github.com/daleharvey/pouchdb/issues/126but luckily it magically disappeared for them when they cleared out the db. I have a objectstore clearfunction, but it didn't work for me. It's a pity the API doesn't come with a reset database (would be great for testing).