2

I am receiving the error when trying to load my web app on iOS Safari and iOS Chrome. No errors on private browsing on desktop.

I added the following:

if (window.indexedDB) {
  console.log('IDB supported');
  var db = new Dexie('Stir');
  //Dexie stuff
}

Using the Safari dev tools, "IDB supported" is being logged - but then the error/alert pops up and is impeding actions.

I have all of my dexie code wrapped inside if (window.indexedDB) - to make sure it is only run if IDB is available in the browser.

My full repo is available at https://github.com/georgecook92/Stir. If looking at this code, the calls to dexie are in the actions index.js and the main index.js for React.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
George Cook
  • 306
  • 3
  • 12

1 Answers1

4

Dexie can throw that error when the call to indexedDB.open (dB name, version) returns null. A null check was added in the dexie source code in response to the following issue:

https://github.com/dfahlander/Dexie.js/issues/134.

Maybe it would cause less confusion if another error had been used to distinguish it from the real absence of window.indexedDB.

Only Safari has the behavior to ever return null from indexedDB.open (). Reason you see it on ios chrome is because that browser runs on safari underhood due to Apple's license restrictions that forbids any other browser engine else than Safari to run on ios.

David Fahlander
  • 5,058
  • 1
  • 20
  • 19
  • Thank you. Maybe it is my lack of understanding with Dexie, why would it return null? I'm just opening a new db. I have read elsewhere that a shim can be added - will that help? – George Cook Aug 17 '16 at 11:06
  • As I understand it, Safari makes indexedDB.open() return null when called in private mode. This is a ridiculous behavior, indeed, but that's what it does. The shim you've heard about is probably IndexedDBShim that provides an indexedDB API backed by WebSQL. You could use that in combination with Dexie if you find the issues in the indexedDB support of Safari too limiting. Safari 10 will have better indexedDB support though. – David Fahlander Aug 18 '16 at 11:58
  • Ah, I see. It does seem strange, thats browser behaviour for you! I guess it's not much of an issue anyway, I was just intrigued as to why it was having an error. I will have a look at the shim, hopefully they get the browser support sorted before WebSQL is removed from the spec! Thank you for your responses, appreciate it! – George Cook Aug 18 '16 at 19:11