Capacitor SQLite Web: Error: Run: ExecSet: in saveToStore SetDBToStore: undefined

I am currently facing a problem with the Capacitor Community Sqlite Library with Angular Ionic, on desktop web (Chrome used as browser).

@capacitor-community/sqlite

https://www.npmjs.com/package/@capacitor-community/sqlite

The difficult thing is that the error only occurs roughly 1% of the time (1 in 100 times). It’s really hard to reproduce. It might be some sort of race condition triggering in my app.

I sometimes get this error after I refresh my page in the browser:

Error: Run: ExecSet: in saveToStore SetDBToStore: undefined

Error image

so this basically happens whenever I initialize my database with the plugin, whenever I open it

After that error, subsequent calls to my database fail with the same error:

Error: Run: ExecSet: in saveToStore SetDBToStore: undefined

Error: Query: <database-name> database not opened

So far I only noticed this bug on the web but for sure it’s possible that it happens on native too since I am looking into the console less there and I am also not refreshing the page there at all, compared to when developing on the web.

So my quetion basically is, what the cause of this error could be, that undefined is returned.

It has sth to do with the jeepSqliteElement I think, since when looking at the source of SetDBToStore:

static async setDBToStore(mDb, dbName, store) {
    try {
        // export the database
        const data = mDb.export();
        // store the database
        await UtilsStore.saveDBToStore(dbName, data, store);
        return Promise.resolve();
    }
    catch (err) {
        return Promise.reject(`SetDBToStore: ${err.message}`);
    }
}

I am calling the saveToStore method on the web too, mentioned here:

https://github.com/capacitor-community/sqlite/issues/545

I know this might seem like neglible but the app completely breaks for the user every 1/100 refreshes, which might also prevent users from staying on the page in the first place.