Skip to content

Commit

Permalink
added changeset. use latest packages
Browse files Browse the repository at this point in the history
  • Loading branch information
stevensJourney committed Oct 24, 2023
1 parent 1128df9 commit ca458d3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilled-walls-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@journeyapps/powersync-sdk-react-native': patch
'@journeyapps/powersync-sdk-common': patch
---

Updated logic to correspond with React Native Quick SQLite concurrent transactions. Added helper methods on transaction contexts.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ export const DEFAULT_POWERSYNC_DB_OPTIONS = {
logger: Logger.get('PowerSyncDatabase')
};

/**
* Requesting nested or recursive locks can block the application in some circumstances.
* This default lock timeout will act as a failsafe to throw an error if a lock cannot
* be obtained.
*/
export const DEFAULT_LOCK_TIMEOUT_MS = 120_000; // 2 mins

export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDBListener> {
/**
* Transactions should be queued in the DBAdapter, but we also want to prevent
Expand Down Expand Up @@ -353,7 +360,10 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
});
}

async readTransaction<T>(callback: (tx: Transaction) => Promise<T>, lockTimeout?: number): Promise<T> {
async readTransaction<T>(
callback: (tx: Transaction) => Promise<T>,
lockTimeout: number = DEFAULT_LOCK_TIMEOUT_MS
): Promise<T> {
await this.initialized;
return this.database.readTransaction(
async (tx) => {
Expand All @@ -365,7 +375,10 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
);
}

async writeTransaction<T>(callback: (tx: Transaction) => Promise<T>, lockTimeout?: number): Promise<T> {
async writeTransaction<T>(
callback: (tx: Transaction) => Promise<T>,
lockTimeout: number = DEFAULT_LOCK_TIMEOUT_MS
): Promise<T> {
await this.initialized;
return this.database.writeTransaction(
async (tx) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/powersync-sdk-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"homepage": "https://docs.powersync.co/",
"peerDependencies": {
"@journeyapps/react-native-quick-sqlite": "0.0.0-dev-20231023173642",
"@journeyapps/react-native-quick-sqlite": "0.0.0-dev-20231024112335",
"base-64": "^1.0.0",
"react": "*",
"react-native-fetch-api": "^3.0.0",
Expand All @@ -40,7 +40,7 @@
"async-lock": "^1.4.0"
},
"devDependencies": {
"@journeyapps/react-native-quick-sqlite": "0.0.0-dev-20231023173642",
"@journeyapps/react-native-quick-sqlite": "0.0.0-dev-20231024112335",
"@types/async-lock": "^1.4.0",
"react": "18.2.0",
"typescript": "^4.1.3"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2134,10 +2134,10 @@
"@types/yargs" "^17.0.8"
chalk "^4.0.0"

"@journeyapps/[email protected]20231023173642":
version "0.0.0-dev-20231023173642"
resolved "https://registry.npmjs.org/@journeyapps/react-native-quick-sqlite/-/react-native-quick-sqlite-0.0.0-dev-20231023173642.tgz#00cfd6aec9674519ffbbc06245e7ce4ce42a0bcb"
integrity sha512-Na4XDi2u5AUZw+/mflV6LLIHJJvfvJxp5uYMDZtG+4WZ4dw0NDq+sZk+U26T/IU9xgdDWlcmwVKku9dDHLt7eg==
"@journeyapps/[email protected]20231024112335":
version "0.0.0-dev-20231024112335"
resolved "https://registry.npmjs.org/@journeyapps/react-native-quick-sqlite/-/react-native-quick-sqlite-0.0.0-dev-20231024112335.tgz#a386b718baef17cb1d51eebaa0487cc5cf19a864"
integrity sha512-Jpn+OSQ39xyJ6rnw06XPPHo1YrnCDOrZPaYGvVUEvUgjcMFYfmJ5YH0StM+/KnUcatKxksXYWyPiBqWO/Gg+hA==
dependencies:
lodash "^4.17.21"

Expand Down

0 comments on commit ca458d3

Please sign in to comment.