Skip to content

Commit a4895cc

Browse files
authored
OPSLite: Silencing transactions that are reporting on failed rollbacks (#483)
1 parent aa84a6c commit a4895cc

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

.changeset/thin-panthers-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/op-sqlite': patch
3+
---
4+
5+
Silencing transactions that are reporting on failed rollback exceptions when they are safe to ignore.

packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
import {
2-
BaseObserver,
3-
DBAdapter,
4-
DBAdapterListener,
5-
DBLockOptions,
6-
QueryResult,
7-
Transaction
8-
} from '@powersync/common';
9-
import {
10-
ANDROID_DATABASE_PATH,
11-
getDylibPath,
12-
IOS_LIBRARY_PATH,
13-
open,
14-
type DB
15-
} from '@op-engineering/op-sqlite';
1+
import { BaseObserver, DBAdapter, DBAdapterListener, DBLockOptions, QueryResult, Transaction } from '@powersync/common';
2+
import { ANDROID_DATABASE_PATH, getDylibPath, IOS_LIBRARY_PATH, open, type DB } from '@op-engineering/op-sqlite';
163
import Lock from 'async-lock';
174
import { OPSQLiteConnection } from './OPSQLiteConnection';
185
import { Platform } from 'react-native';
@@ -283,7 +270,12 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
283270
await commit();
284271
return result;
285272
} catch (ex) {
286-
await rollback();
273+
try {
274+
await rollback();
275+
} catch (ex2) {
276+
// In rare cases, a rollback may fail.
277+
// Safe to ignore.
278+
}
287279
throw ex;
288280
}
289281
}
@@ -292,7 +284,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
292284
await this.initialized;
293285
await this.writeConnection!.refreshSchema();
294286

295-
if(this.readConnections) {
287+
if (this.readConnections) {
296288
for (let readConnection of this.readConnections) {
297289
await readConnection.connection.refreshSchema();
298290
}

0 commit comments

Comments
 (0)