Skip to content

Commit 44fcb6e

Browse files
authored
Merge branch 'main' into locks
2 parents dcd163d + fe98172 commit 44fcb6e

29 files changed

+655
-558
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/common': patch
3+
---
4+
5+
Changed priorityStatusEntries() to no longer depend on toSorted(), which isn't natively available in React-Native.

.changeset/loud-mangos-kick.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@powersync/common': patch
3+
'@powersync/web': patch
4+
---
5+
6+
Fixed race condition in async closing of databases

demos/django-react-native-todolist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"@azure/core-asynciterator-polyfill": "^1.0.2",
1212
"@expo/vector-icons": "^14.0.0",
13-
"@journeyapps/react-native-quick-sqlite": "^2.3.0",
13+
"@journeyapps/react-native-quick-sqlite": "^2.4.1",
1414
"@powersync/common": "workspace:*",
1515
"@powersync/react": "workspace:*",
1616
"@powersync/react-native": "workspace:*",

demos/react-native-supabase-group-chat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@azure/core-asynciterator-polyfill": "^1.0.2",
2323
"@faker-js/faker": "8.3.1",
24-
"@journeyapps/react-native-quick-sqlite": "^2.3.0",
24+
"@journeyapps/react-native-quick-sqlite": "^2.4.1",
2525
"@powersync/common": "workspace:*",
2626
"@powersync/react": "workspace:*",
2727
"@powersync/react-native": "workspace:*",

demos/react-native-supabase-todolist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"@azure/core-asynciterator-polyfill": "^1.0.2",
1212
"@expo/vector-icons": "^14.0.3",
13-
"@journeyapps/react-native-quick-sqlite": "^2.3.0",
13+
"@journeyapps/react-native-quick-sqlite": "^2.4.1",
1414
"@powersync/attachments": "workspace:*",
1515
"@powersync/common": "workspace:*",
1616
"@powersync/react": "workspace:*",

demos/react-native-web-supabase-todolist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@azure/core-asynciterator-polyfill": "^1.0.2",
1414
"@expo/metro-runtime": "^3.2.1",
1515
"@expo/vector-icons": "^14.0.0",
16-
"@journeyapps/react-native-quick-sqlite": "^2.3.0",
16+
"@journeyapps/react-native-quick-sqlite": "^2.4.1",
1717
"@powersync/attachments": "workspace:*",
1818
"@powersync/common": "workspace:*",
1919
"@powersync/react": "workspace:*",

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
"@actions/core": "^1.10.1",
3434
"@changesets/cli": "2.27.2",
3535
"@pnpm/workspace.find-packages": "^4.0.2",
36-
"@vitest/browser": "^3.0.5",
36+
"@vitest/browser": "^3.0.8",
3737
"husky": "^9.0.11",
3838
"lint-staged": "^15.2.2",
39-
"playwright": "^1.50.1",
39+
"playwright": "^1.51.0",
4040
"prettier": "^3.2.5",
4141
"typescript": "^5.7.2",
42-
"vitest": "^3.0.5"
42+
"vitest": "^3.0.8"
4343
}
4444
}

packages/common/src/client/AbstractPowerSyncDatabase.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ import { mutexRunExclusive } from '../utils/mutex.js';
1818
import { throttleTrailing } from '../utils/throttle.js';
1919
import { SQLOpenFactory, SQLOpenOptions, isDBAdapter, isSQLOpenFactory, isSQLOpenOptions } from './SQLOpenFactory.js';
2020
import { PowerSyncBackendConnector } from './connection/PowerSyncBackendConnector.js';
21+
import { runOnSchemaChange } from './runOnSchemaChange.js';
2122
import { BucketStorageAdapter, PSInternalTable } from './sync/bucket/BucketStorageAdapter.js';
2223
import { CrudBatch } from './sync/bucket/CrudBatch.js';
2324
import { CrudEntry, CrudEntryJSON } from './sync/bucket/CrudEntry.js';
2425
import { CrudTransaction } from './sync/bucket/CrudTransaction.js';
2526
import {
2627
DEFAULT_CRUD_UPLOAD_THROTTLE_MS,
27-
type AdditionalConnectionOptions,
28-
type PowerSyncConnectionOptions,
28+
DEFAULT_RETRY_DELAY_MS,
2929
StreamingSyncImplementation,
3030
StreamingSyncImplementationListener,
31-
DEFAULT_RETRY_DELAY_MS,
31+
type AdditionalConnectionOptions,
32+
type PowerSyncConnectionOptions,
3233
type RequiredAdditionalConnectionOptions
3334
} from './sync/stream/AbstractStreamingSyncImplementation.js';
34-
import { runOnSchemaChange } from './runOnSchemaChange.js';
3535

3636
export interface DisconnectAndClearOptions {
3737
/** When set to false, data in local-only tables is preserved. */
@@ -505,13 +505,17 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
505505
async close(options: PowerSyncCloseOptions = DEFAULT_POWERSYNC_CLOSE_OPTIONS) {
506506
await this.waitForReady();
507507

508+
if (this.closed) {
509+
return;
510+
}
511+
508512
const { disconnect } = options;
509513
if (disconnect) {
510514
await this.disconnect();
511515
}
512516

513517
await this.syncStreamImplementation?.dispose();
514-
this.database.close();
518+
await this.database.close();
515519
this.closed = true;
516520
}
517521

packages/common/src/db/DBAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export interface DBLockOptions {
9393
}
9494

9595
export interface DBAdapter extends BaseObserverInterface<DBAdapterListener>, DBGetUtils {
96-
close: () => void;
96+
close: () => void | Promise<void>;
9797
execute: (query: string, params?: any[]) => Promise<QueryResult>;
9898
executeBatch: (query: string, params?: any[][]) => Promise<QueryResult>;
9999
name: string;

packages/common/src/db/crud/SyncStatus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class SyncStatus {
7171
* Partial sync status for involved bucket priorities.
7272
*/
7373
get priorityStatusEntries() {
74-
return (this.options.priorityStatusEntries ?? []).toSorted(SyncStatus.comparePriorities);
74+
return (this.options.priorityStatusEntries ?? []).slice().sort(SyncStatus.comparePriorities);
7575
}
7676

7777
/**

0 commit comments

Comments
 (0)