Alex
Alex

Reputation: 185

DATA_ERR: DOM IDBDatabase Exception 5 in Chrome, how to fix?

Code like this:

var transaction = db.transaction(["main"], IDBTransaction.READ_WRITE);
var store = transaction.objectStore("main");
var request = store.add(object);

It work correctly in Firefox, but in Chrome it throws "DATA_ERR: DOM IDBDatabase Exception 5" at the last line. What does this exception means? How to fix it?

Upvotes: 2

Views: 1800

Answers (4)

DannyLi
DannyLi

Reputation: 11

This error can be caused by many reasons. I believe it could be the bug on Linux Chrome Version 22.0.1197.0 (145517). I used the same code, Firefox worked but Chrome raised this error. I tried to clear everything. Finally I started Chrome with the command:

./chrome --user-data-dir=/tmp/chrome

and it worked.

Upvotes: 1

Karra
Karra

Reputation: 669

This has happened to me on at least 2 distinct occasions: (a) when I upgraded the database version, and was writing to the older version, and (b) another case when it bizarrely got fixed by adding onerror and onsuccess handler, like so. Perhaps one of these would work for you...

req.onerror = function () {
    console.log("Oppsie!");
}
req.onsuccess = function () {
    console.log("Hurrah!");
}

Upvotes: 1

surya
surya

Reputation: 1359

If your ObjectStore has autoIncrement:true, Chrome throws this error. [source]

Upvotes: 2

buley
buley

Reputation: 29208

IndexedDB Exception 5 means that the "Data provided to an operation does not meet requirements." This is typically because you've added a unique index, for example, while providing an object missing that attribute.

My guess would be that you're missing an indexed attribute, but to answer this question with certainty I'd need to see your main objectStore setup code and a JSON representation of the object.

Upvotes: 1

Related Questions