{"id":8107,"date":"2015-11-26T13:40:19","date_gmt":"2015-11-26T13:40:19","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/26\/overcoming-securityerror-dom-exception-18-in-pouchdb-on-mobile-chrome-for-ios-open-source-projects-pouchdb-pouchdb\/"},"modified":"2022-08-30T15:03:00","modified_gmt":"2022-08-30T15:03:00","slug":"overcoming-securityerror-dom-exception-18-in-pouchdb-on-mobile-chrome-for-ios-open-source-projects-pouchdb-pouchdb","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/26\/overcoming-securityerror-dom-exception-18-in-pouchdb-on-mobile-chrome-for-ios-open-source-projects-pouchdb-pouchdb\/","title":{"rendered":"Overcoming SecurityError: DOM Exception 18 in PouchDB on Mobile Chrome for iOS-open source projects pouchdb\/pouchdb"},"content":{"rendered":"<p>I am using PouchDB 3.2.1 on a web application targeted for Chrome on iOS. The below error also appears in PouchDB 3.2.0.<\/p>\n<p>When trying to create a connection to a local database on Chrome on iOS, PouchDB uses that browser&#8217;s WebSQL database. This, however, fails intermittently with SecurityError: DOM Exception 18 when running the application on both iPhone 5 and iPhone 5s. I have not been able to reproduce this error on my iPad 5 yet.<\/p>\n<p>I am creating a new PouchDB database as follows:<\/p>\n<pre><code>var localDBName = \"dbd8008497c6f368d\";\nself.localPouch = new PouchDB(localDBName, {size: 50});\n<\/code><\/pre>\n<p>I have also tried setting size to 49, 1, and 0 and not setting size at all.<\/p>\n<p>Here is a stacktrace sourced from BugSnag:<\/p>\n<pre><code>[native code]:4232 openDatabase\nhttp:\/\/192.168.1.144:8000\/app\/bower_components\/pouchdb\/dist\/pouchdb.js:4232:48 openDB\nhttp:\/\/192.168.1.144:8000\/app\/bower_components\/pouchdb\/dist\/pouchdb.js:4275:18 WebSqlPouch\nhttp:\/\/192.168.1.144:8000\/app\/bower_components\/pouchdb\/dist\/pouchdb.js:5655:40\n[native code]:0 Promise\nhttp:\/\/192.168.1.144:8000\/app\/bower_components\/pouchdb\/dist\/pouchdb.js:5570:28 PouchDB\n<\/code><\/pre>\n<p>Here is the code near line 4232 of pouchdb.js:<\/p>\n<pre><code>var cachedDatabases = {};\n\nvar openDBFunction = (typeof navigator !== 'undefined' &amp;&amp;\n      navigator.sqlitePlugin &amp;&amp;\n      navigator.sqlitePlugin.openDatabase) ?\n    navigator.sqlitePlugin.openDatabase.bind(navigator.sqlitePlugin) :\n      (typeof sqlitePlugin !== 'undefined' &amp;&amp; sqlitePlugin.openDatabase) ?\n    sqlitePlugin.openDatabase.bind(sqlitePlugin) :\n      (typeof openDatabase !== 'undefined') ?\n    openDatabase :\n    null;\n\nfunction openDB(name, version, desc, size) {\n  var db = cachedDatabases[name];\n  if (!db) {\n    db = cachedDatabases[name] = openDBFunction(name, version, desc, size);\n  }\n  return db;\n}\n<\/code><\/pre>\n<p>Refreshing the the browser page does not fix the issue. Neither does closing the browser tab and re-opening the page. The only way I can fix the issue is by force-quitting the browser and relaunching the application. However, this is not an acceptable workaround for our users.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am using PouchDB 3.2.1 on a web application targeted for Chrome on iOS. The below error also appears in PouchDB 3.2.0. When trying to create a connection to a local database on Chrome on iOS, PouchDB uses that browser&#8217;s WebSQL database. This, however, fails intermittently with SecurityError: DOM Exception 18 when running the application [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8107","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8107"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8107\/revisions"}],"predecessor-version":[{"id":8616,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8107\/revisions\/8616"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}