diff --git a/.changeset/thin-panthers-decide.md b/.changeset/thin-panthers-decide.md new file mode 100644 index 000000000..da404afee --- /dev/null +++ b/.changeset/thin-panthers-decide.md @@ -0,0 +1,5 @@ +--- +'@powersync/op-sqlite': patch +--- + +Silencing transactions that are reporting on failed rollback exceptions when they are safe to ignore. diff --git a/packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts b/packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts index 6880963cc..7b2423656 100644 --- a/packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts +++ b/packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts @@ -1,18 +1,5 @@ -import { - BaseObserver, - DBAdapter, - DBAdapterListener, - DBLockOptions, - QueryResult, - Transaction -} from '@powersync/common'; -import { - ANDROID_DATABASE_PATH, - getDylibPath, - IOS_LIBRARY_PATH, - open, - type DB -} from '@op-engineering/op-sqlite'; +import { BaseObserver, DBAdapter, DBAdapterListener, DBLockOptions, QueryResult, Transaction } from '@powersync/common'; +import { ANDROID_DATABASE_PATH, getDylibPath, IOS_LIBRARY_PATH, open, type DB } from '@op-engineering/op-sqlite'; import Lock from 'async-lock'; import { OPSQLiteConnection } from './OPSQLiteConnection'; import { Platform } from 'react-native'; @@ -283,7 +270,12 @@ export class OPSQLiteDBAdapter extends BaseObserver implement await commit(); return result; } catch (ex) { - await rollback(); + try { + await rollback(); + } catch (ex2) { + // In rare cases, a rollback may fail. + // Safe to ignore. + } throw ex; } } @@ -292,7 +284,7 @@ export class OPSQLiteDBAdapter extends BaseObserver implement await this.initialized; await this.writeConnection!.refreshSchema(); - if(this.readConnections) { + if (this.readConnections) { for (let readConnection of this.readConnections) { await readConnection.connection.refreshSchema(); }