Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidStateError on Firefox #312

Open
julienfouilhe opened this issue Sep 13, 2016 · 9 comments
Open

InvalidStateError on Firefox #312

julienfouilhe opened this issue Sep 13, 2016 · 9 comments

Comments

@julienfouilhe
Copy link

julienfouilhe commented Sep 13, 2016

Hi,

For some time now, I've seen a recurring error: InvalidStateError

InvalidStateError occurred when opening database database_name. A mutation operation was attempted on a database that did not allow mutations.

This happens with this simple code:

  var db = new Dexie('database_name');
  db.version(2).stores({ actions: '++_id, *scoreId, &id' });

  db.open().then(function() {
    // not entering there
  }.bind(this)).catch(function(err) {
    // catching invalid state error
  }.bind(this));

It only happens on Firefox (v39 to v48), rarely though. I was never able to reproduce it, I've only seen this happen to my users, via bug reporting.

I've seen this link that seems to be related but I can't figure out what I'm doing wrong: http://stackoverflow.com/questions/24295588/indexeddb-error-in-firefox-when-calling-createobjectstore

@julienfouilhe julienfouilhe changed the title InvalidStateError InvalidStateError on Safari Sep 13, 2016
@julienfouilhe julienfouilhe changed the title InvalidStateError on Safari InvalidStateError on Firefox Sep 13, 2016
@julienfouilhe
Copy link
Author

julienfouilhe commented Sep 13, 2016

Seems to be produced when using private navigation. I guess this is related to the way Firefox handles storing data in private mode. Safari throws a MissingAPIError too.

I think that the fact that IndexedDB does not work in private mode for those browsers should be put forward in the documentation. It would save time to a lot of developers. Not Dexie's fault but nice to mention anyway! ;)

@dfahlander
Copy link
Collaborator

Ok, thanks for sharing this. I don't get why cookies are allowed but not indexedDB. Probably due to the lack of a RAM memory based indexeddb implementation.

I could write some doc about this issue and how to give users a better experience than just obscure error messages. It might be useful to update dexie to give a common error for errors due to private browsing. I'll see what I could do about it.

@dev0x10
Copy link

dev0x10 commented Oct 2, 2016

When trying to set in private browser there will be an error thrown

DexieError {_e: Error, name: "OpenFailedError", message: "QuotaExceededError The quota has been exceeded.", inner: DexieError, _stack: "OpenFailedError: QuotaExceededError The quota has …/prototype.testing.com/app.bundle.js:53871:50", …}

That quota ExceededError is same error thrown when trying to use localStorage on Safari private browsing
This means Dexie doesn't support private browsing, right?

@julienfouilhe
Copy link
Author

julienfouilhe commented Oct 2, 2016

@dev0x10 I've had this one too and it seems to mean that the user's disk is full and therefore browser denies opening a database

@dev0x10
Copy link

dev0x10 commented Oct 2, 2016

@julienfouilhe oh yes user's disk full also can cause that problem. But mostly it is happen because of private browsing mode, especially in Safari
I'd like to know if there is a workaround for using Dexie in private browsing mode

@dev0x10
Copy link

dev0x10 commented Oct 2, 2016

@indolering
Copy link

There really should be a more informative warning for when IndexedDB isn't available....

@DemersM
Copy link

DemersM commented Apr 6, 2017

People at Firefox are working (slowly) to fix the issue and to enable IndexedDB in private mode: https://bugzilla.mozilla.org/show_bug.cgi?id=781982

@NelsonMinar
Copy link

According to MDN docs the only browser that supports IndexedDB in private mode is Chrome.
https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API#Browser_compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants