@powersync/web 0.0.0-dev-20251119142638 → 0.0.0-dev-20251120085122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.js +21 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +14 -6
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +28 -34
- package/dist/worker/WASQLiteDB.umd.js.map +1 -1
- package/lib/src/db/adapters/AsyncDatabaseConnection.d.ts +13 -0
- package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.d.ts +1 -0
- package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js +7 -2
- package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +5 -0
- package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js +7 -0
- package/lib/src/worker/db/SharedWASQLiteConnection.d.ts +4 -3
- package/lib/src/worker/db/SharedWASQLiteConnection.js +17 -17
- package/lib/src/worker/db/WASQLiteDB.worker.js +2 -2
- package/lib/src/worker/db/WorkerWASQLiteConnection.d.ts +3 -3
- package/lib/src/worker/db/WorkerWASQLiteConnection.js +2 -14
- package/lib/src/worker/sync/SharedSyncImplementation.d.ts +2 -2
- package/lib/src/worker/sync/SharedSyncImplementation.js +7 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/db/adapters/AsyncDatabaseConnection.ts +13 -0
- package/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts +8 -2
- package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +8 -0
- package/src/worker/db/SharedWASQLiteConnection.ts +23 -20
- package/src/worker/db/WASQLiteDB.worker.ts +2 -2
- package/src/worker/db/WorkerWASQLiteConnection.ts +3 -18
- package/src/worker/sync/SharedSyncImplementation.ts +15 -12
|
@@ -14423,10 +14423,13 @@ class WorkerWrappedAsyncDatabaseConnection {
|
|
|
14423
14423
|
this.notifyRemoteClosed.abort();
|
|
14424
14424
|
}
|
|
14425
14425
|
markHold() {
|
|
14426
|
-
return this.baseConnection.markHold();
|
|
14426
|
+
return this.withRemote(() => this.baseConnection.markHold());
|
|
14427
14427
|
}
|
|
14428
14428
|
releaseHold(holdId) {
|
|
14429
|
-
return this.baseConnection.releaseHold(holdId);
|
|
14429
|
+
return this.withRemote(() => this.baseConnection.releaseHold(holdId));
|
|
14430
|
+
}
|
|
14431
|
+
isAutoCommit() {
|
|
14432
|
+
return this.baseConnection.isAutoCommit();
|
|
14430
14433
|
}
|
|
14431
14434
|
withRemote(workerPromise) {
|
|
14432
14435
|
const controller = this.notifyRemoteClosed;
|
|
@@ -14434,6 +14437,8 @@ class WorkerWrappedAsyncDatabaseConnection {
|
|
|
14434
14437
|
return new Promise((resolve, reject) => {
|
|
14435
14438
|
if (controller.signal.aborted) {
|
|
14436
14439
|
reject(new Error('Called operation on closed remote'));
|
|
14440
|
+
// Don't run the operation if we're going to reject
|
|
14441
|
+
return;
|
|
14437
14442
|
}
|
|
14438
14443
|
function handleAbort() {
|
|
14439
14444
|
reject(new Error('Remote peer closed with request in flight'));
|
|
@@ -15118,11 +15123,14 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
15118
15123
|
return () => { };
|
|
15119
15124
|
}
|
|
15120
15125
|
for (const closeListener of trackedPort.closeListeners) {
|
|
15121
|
-
closeListener();
|
|
15126
|
+
await closeListener();
|
|
15122
15127
|
}
|
|
15123
15128
|
if (this.dbAdapter && this.dbAdapter == trackedPort.db) {
|
|
15124
15129
|
// Unconditionally close the connection because the database it's writing to has just been closed.
|
|
15125
|
-
|
|
15130
|
+
// The connection has been closed previously, this might throw. We should be able to ignore it.
|
|
15131
|
+
await this.connectionManager
|
|
15132
|
+
.disconnect()
|
|
15133
|
+
.catch((ex) => this.logger.warn('Error while disconnecting. Will attempt to reconnect.', ex));
|
|
15126
15134
|
// Clearing the adapter will result in a new one being opened in connect
|
|
15127
15135
|
this.dbAdapter = null;
|
|
15128
15136
|
if (shouldReconnect) {
|
|
@@ -15251,9 +15259,9 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
15251
15259
|
// that and ensure pending requests are aborted when the tab is closed.
|
|
15252
15260
|
remoteCanCloseUnexpectedly: true
|
|
15253
15261
|
});
|
|
15254
|
-
lastClient.closeListeners.push(() => {
|
|
15262
|
+
lastClient.closeListeners.push(async () => {
|
|
15255
15263
|
this.logger.info('Aborting open connection because associated tab closed.');
|
|
15256
|
-
wrapped.close();
|
|
15264
|
+
await wrapped.close().catch((ex) => this.logger.warn('error closing database connection', ex));
|
|
15257
15265
|
wrapped.markRemoteClosed();
|
|
15258
15266
|
});
|
|
15259
15267
|
return wrapped;
|