Pouchdb - Open database failed on android 12

836 Views Asked by At

I have a project of ionic 5 with capacitor and when I try to open pouchdb database with:

let pdb = new PouchDB('msg.db', {
      adapter: 'cordova-sqlite',
      location: 'default',
      revs_limit: 1,
      auto_compaction: true
    });

It failed with the following logs:

pouchdb:adapter Picked adapter:  +0ms cordova-sqlite
my-groups:6463 OPEN database: msg.db
my-groups:6394 new transaction is queued, waiting for open operation to finish
my-groups:6485 OPEN database: msg.db FAILED, aborting any pending transactions
my-groups:6371 Could not open database
index-browser.es.js:451 WebSQL threw an error Error: Invalid database handle
    at newSQLError (my-groups:6314:18)
    at SQLitePlugin.abortAllPendingTransactions (my-groups:6446:23)
    at my-groups:6490:17
    at Object.callbackFromNative (my-groups:1224:46)
    at <anonymous>:1:9
    at DbService.createPouchDB (db.service.ts:40:5)
    at new PchatService (pchat.service.ts:43:33)
    at Object.PchatService_Factory [as factory] (ɵfac.js? [sm]:1:1)
    at R3Injector.hydrate (core.js:11452:1)
    at R3Injector.get (core.js:11272:1)

It happens on android 12 (maybe on 11 too) but not on android 10.

Any idea how to fix it?

1

There are 1 best solutions below

0
RafaelJan On

Thanks to @RamblinRose and @MishaMashina comments, I found that, upgrade cordova-sqlite-storage plugin to version 6.0.0, solved the issue