cry-synced-db-client 0.1.210 → 0.1.212

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Versions
2
2
 
3
+ ## 0.1.211 (2026-06-25)
4
+
5
+ ### Added `streamActivityTimeoutMs` to SyncedDbConfig
6
+
7
+ `findNewerManyStream` has two internal timeouts: `connectTimeout` (configurable via
8
+ `defaultTimeoutMs`) and `activityTimeout` (was hardcoded to 30s). The activity
9
+ timeout fires between stream chunk reads — if Dexie writes + Vuex reactivity for
10
+ a 2000-item chunk exceed 30s, the stream is aborted.
11
+
12
+ New fields:
13
+ - `RestProxy.defaultActivityTimeoutMs` — default for all streams (falls back to 30s)
14
+ - `SyncedDbConfig.streamActivityTimeoutMs` — threaded through SyncedDb → SyncEngine
15
+ → RestProxy.findNewerManyStream(options.activityTimeoutMs)
16
+
3
17
  ## 0.1.209 (2026-06-25)
4
18
 
5
19
  ### Removed hardcoded `{ returnDeleted: true }` from sync specs
package/dist/index.js CHANGED
@@ -3332,7 +3332,8 @@ var _SyncEngine = class _SyncEngine {
3332
3332
  },
3333
3333
  onResponseChunkBytes: (bytes) => {
3334
3334
  responseBytes = (responseBytes != null ? responseBytes : 0) + bytes;
3335
- }
3335
+ },
3336
+ activityTimeoutMs: this.deps.streamActivityTimeoutMs
3336
3337
  }
3337
3338
  ),
3338
3339
  "findNewerManyStream"
@@ -5087,6 +5088,7 @@ var _SyncedDb = class _SyncedDb {
5087
5088
  },
5088
5089
  getInMemById: (collection, id) => this.inMemDb.getById(collection, id),
5089
5090
  withSyncTimeout: (promise, operation) => this.connectionManager.withSyncTimeout(promise, operation),
5091
+ streamActivityTimeoutMs: config.streamActivityTimeoutMs,
5090
5092
  onSyncFailed: (reason) => this.connectionManager.callOnSyncFailed(reason),
5091
5093
  flushAllPendingChanges: () => this.pendingChanges.flushAll(),
5092
5094
  cancelRestUploadTimer: () => this.pendingChanges.cancelRestUploadTimer(),
@@ -10452,16 +10454,17 @@ var RestProxy = class {
10452
10454
  this._lastRequestMs = 0;
10453
10455
  this._totalRequestMs = 0;
10454
10456
  this._requestCount = 0;
10455
- var _a, _b, _c, _d, _e;
10457
+ var _a, _b, _c, _d, _e, _f;
10456
10458
  this.endpoint = config.endpoint;
10457
10459
  this.tenant = config.tenant;
10458
10460
  this.apiKey = config.apiKey;
10459
10461
  this.defaultTimeoutMs = (_a = config.defaultTimeoutMs) != null ? _a : DEFAULT_TIMEOUT;
10460
- this.audit = (_b = config.audit) != null ? _b : {};
10461
- this.timeRequestsPrint = (_c = config.timeRequestsPrint) != null ? _c : false;
10462
- this.timeRequests = (_d = config.timeRequests) != null ? _d : this.timeRequestsPrint;
10462
+ this.defaultActivityTimeoutMs = (_b = config.defaultActivityTimeoutMs) != null ? _b : 3e4;
10463
+ this.audit = (_c = config.audit) != null ? _c : {};
10464
+ this.timeRequestsPrint = (_d = config.timeRequestsPrint) != null ? _d : false;
10465
+ this.timeRequests = (_e = config.timeRequests) != null ? _e : this.timeRequestsPrint;
10463
10466
  this.onProgressCallback = config.onProgressCallback;
10464
- this.progressChunkSize = (_e = config.progressChunkSize) != null ? _e : DEFAULT_PROGRESS_CHUNK_SIZE;
10467
+ this.progressChunkSize = (_f = config.progressChunkSize) != null ? _f : DEFAULT_PROGRESS_CHUNK_SIZE;
10465
10468
  this.globalSignal = config.signal;
10466
10469
  }
10467
10470
  /** Set global abort signal */
@@ -10638,7 +10641,7 @@ var RestProxy = class {
10638
10641
  async findNewerManyStream(spec, onChunk, options) {
10639
10642
  var _a, _b, _c, _d, _e;
10640
10643
  const connectTimeout = (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : this.defaultTimeoutMs;
10641
- const activityTimeout = (_b = options == null ? void 0 : options.activityTimeoutMs) != null ? _b : 3e4;
10644
+ const activityTimeout = (_b = options == null ? void 0 : options.activityTimeoutMs) != null ? _b : this.defaultActivityTimeoutMs;
10642
10645
  const externalSignal = (_c = options == null ? void 0 : options.signal) != null ? _c : this.globalSignal;
10643
10646
  const startTime = this.timeRequests ? performance.now() : 0;
10644
10647
  const fetchStart = performance.now();
@@ -13,6 +13,17 @@ export interface RestProxyConfig {
13
13
  apiKey?: string;
14
14
  /** Default timeout in ms (default: 5000) */
15
15
  defaultTimeoutMs?: number;
16
+ /**
17
+ * Default activity timeout for streaming responses (default: 30000).
18
+ *
19
+ * Unlike `defaultTimeoutMs` which covers the initial fetch() connection,
20
+ * this timeout fires if the gap between individual chunk reads exceeds
21
+ * the limit. Streaming syncs with many large collections (e.g. initial
22
+ * sync on a new device with 60+ collections and 2000-item chunks) need
23
+ * a higher value because Dexie writes + Vuex reactivity between reads
24
+ * can delay the next read() past the default 30s.
25
+ */
26
+ defaultActivityTimeoutMs?: number;
16
27
  /** Audit info for requests */
17
28
  audit?: {
18
29
  user?: string;
@@ -64,6 +75,7 @@ export declare class RestProxy implements I_RestInterface {
64
75
  private tenant;
65
76
  private apiKey?;
66
77
  private defaultTimeoutMs;
78
+ private defaultActivityTimeoutMs;
67
79
  private audit;
68
80
  private timeRequests;
69
81
  private timeRequestsPrint;
@@ -282,6 +282,8 @@ export interface SyncEngineDeps {
282
282
  }) => void;
283
283
  getInMemById: <T extends DbEntity>(collection: string, id: Id) => T | undefined;
284
284
  withSyncTimeout: <T>(promise: Promise<T>, operation: string) => Promise<T>;
285
+ /** Activity timeout for streaming `findNewerManyStream` (ms). Default 30000. */
286
+ streamActivityTimeoutMs?: number;
285
287
  /** Notify consumers that a sync cycle failed. Does not mutate online state. */
286
288
  onSyncFailed: (reason: string) => void;
287
289
  flushAllPendingChanges: () => Promise<void>;
@@ -133,6 +133,7 @@ export interface I_RestInterface {
133
133
  findNewerManyStream<T>(spec: GetNewerSpec<T>[], onChunk: (collection: string, items: T[], specId?: string) => Promise<void>, options?: {
134
134
  timeoutMs?: number;
135
135
  signal?: AbortSignal;
136
+ activityTimeoutMs?: number;
136
137
  onRequestBytes?: (bytes: number) => void;
137
138
  onTtfbMs?: (ms: number) => void;
138
139
  onResponseChunkBytes?: (bytes: number) => void;
@@ -592,6 +592,16 @@ export interface SyncedDbConfig {
592
592
  restTimeoutMs?: number;
593
593
  /** Timeout za sync REST klice v ms (default: 120000) - daljši ker sync prenaša več podatkov */
594
594
  syncTimeoutMs?: number;
595
+ /**
596
+ * Activity timeout za streaming odgovore (default: 30000).
597
+ *
598
+ * Za razliko od `restTimeoutMs` (ki pokriva začetno fetch() povezavo),
599
+ * ta timeout sproži če je premor med posameznimi chunk read()-i daljši
600
+ * od meje. Initial sync na novi napravi (60+ kolekcij, 2000-item chunk-i)
601
+ * potrebuje višjo vrednost, ker Dexie writes + Vuex reactivity med read()-i
602
+ * lahko podaljšajo naslednji read() čez privzetih 30s.
603
+ */
604
+ streamActivityTimeoutMs?: number;
595
605
  /** Debounce čas za zapis v Dexie v ms (default: 200) */
596
606
  debounceDexieWritesMs?: number;
597
607
  /** Debounce čas za pošiljanje na REST v ms (default: 1000) - po uspešnem zapisu v Dexie */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.210",
3
+ "version": "0.1.212",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",