@powersync/common 1.13.0 → 1.14.0

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.
@@ -8,6 +8,16 @@ export interface SQLOpenOptions {
8
8
  * Directory where the database file is located.
9
9
  */
10
10
  dbLocation?: string;
11
+ /**
12
+ * Enable debugMode to log queries to the performance timeline.
13
+ *
14
+ * Defaults to false.
15
+ *
16
+ * To enable in development builds, use:
17
+ *
18
+ * debugMode: process.env.NODE_ENV !== 'production'
19
+ */
20
+ debugMode?: boolean;
11
21
  }
12
22
  export interface SQLOpenFactory {
13
23
  /**
@@ -1,3 +1,4 @@
1
+ import { OpId } from './CrudEntry';
1
2
  import { OplogEntry, OplogEntryJSON } from './OplogEntry';
2
3
  export type SyncDataBucketJSON = {
3
4
  bucket: string;
@@ -17,11 +18,11 @@ export declare class SyncDataBucket {
17
18
  /**
18
19
  * The `after` specified in the request.
19
20
  */
20
- after?: string | undefined;
21
+ after?: OpId | undefined;
21
22
  /**
22
23
  * Use this for the next request.
23
24
  */
24
- next_after?: string | undefined;
25
+ next_after?: OpId | undefined;
25
26
  static fromRow(row: SyncDataBucketJSON): SyncDataBucket;
26
27
  constructor(bucket: string, data: OplogEntry[],
27
28
  /**
@@ -31,10 +32,10 @@ export declare class SyncDataBucket {
31
32
  /**
32
33
  * The `after` specified in the request.
33
34
  */
34
- after?: string | undefined,
35
+ after?: OpId | undefined,
35
36
  /**
36
37
  * Use this for the next request.
37
38
  */
38
- next_after?: string | undefined);
39
+ next_after?: OpId | undefined);
39
40
  toJSON(): SyncDataBucketJSON;
40
41
  }
@@ -180,8 +180,16 @@ export class AbstractRemote {
180
180
  socketIsClosed = true;
181
181
  rsocket.close();
182
182
  };
183
+ // Helps to prevent double close scenarios
184
+ rsocket.onClose(() => (socketIsClosed = true));
183
185
  // We initially request this amount and expect these to arrive eventually
184
186
  let pendingEventsCount = SYNC_QUEUE_REQUEST_N;
187
+ const disposeClosedListener = stream.registerListener({
188
+ closed: () => {
189
+ closeSocket();
190
+ disposeClosedListener();
191
+ }
192
+ });
185
193
  const socket = await new Promise((resolve, reject) => {
186
194
  let connectionEstablished = false;
187
195
  const res = rsocket.requestStream({
@@ -196,9 +204,8 @@ export class AbstractRemote {
196
204
  if (e.message !== 'Closed. ') {
197
205
  this.logger.error(e);
198
206
  }
199
- // RSocket will close this automatically
200
- // Attempting to close multiple times causes a console warning
201
- socketIsClosed = true;
207
+ // RSocket will close the RSocket stream automatically
208
+ // Close the downstream stream as well - this will close the RSocket connection and WebSocket
202
209
  stream.close();
203
210
  // Handles cases where the connection failed e.g. auth error or connection error
204
211
  if (!connectionEstablished) {
@@ -236,8 +243,7 @@ export class AbstractRemote {
236
243
  }
237
244
  },
238
245
  closed: () => {
239
- closeSocket();
240
- l?.();
246
+ l();
241
247
  }
242
248
  });
243
249
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/common",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -20,7 +20,7 @@
20
20
  "bugs": {
21
21
  "url": "https://github.com/powersync-ja/powersync-js/issues"
22
22
  },
23
- "homepage": "https://docs.powersync.com/resources/api-reference",
23
+ "homepage": "https://docs.powersync.com",
24
24
  "dependencies": {
25
25
  "async-mutex": "^0.4.0",
26
26
  "buffer": "^6.0.3",
@@ -36,7 +36,7 @@
36
36
  "@types/lodash": "^4.14.197",
37
37
  "@types/node": "^20.5.9",
38
38
  "@types/uuid": "^9.0.1",
39
- "typescript": "^5.1.3",
39
+ "typescript": "^5.5.3",
40
40
  "vitest": "^1.5.2",
41
41
  "bson": "^6.6.0"
42
42
  },