@rocicorp/zero 1.11.0-head-e0952422-20260928 → 1.11.0-head-a8a46237-20260928

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.
@@ -314,6 +314,34 @@ export declare class ReplicacheImpl<MD extends MutatorDefs = {}> {
314
314
  beginPull(): Promise<BeginPullResult>;
315
315
  persist(): Promise<void>;
316
316
  refresh(): Promise<void>;
317
+ /**
318
+ * Stops every write to the local store, for an instance whose database is
319
+ * about to be dropped from under it: the store-writing background
320
+ * processes (heartbeat, GC, collection, mutation recovery) are aborted, a
321
+ * `persist()` already in flight is waited for, and every later `persist()`
322
+ * — scheduled or explicit — is a no-op. Mutations keep running against the in-memory
323
+ * dag until the app replaces the instance (see `onClientStateNotFound`).
324
+ *
325
+ * Use together with {@link stopRefresh} before dropping the database, so
326
+ * the drop's own footprint — `database is closed` from the next scheduled
327
+ * persist and the background processes — is not logged as errors against a
328
+ * store that was deleted on purpose.
329
+ */
330
+ stopPersist(): Promise<void>;
331
+ /**
332
+ * Stops every refresh from the local store, for an instance whose database
333
+ * is about to be dropped from under it: the store-reading background
334
+ * process (the new-client channel) is aborted, a `refresh()` already in
335
+ * flight is waited for, and every later `refresh()` / `runRefresh()` —
336
+ * scheduled or explicit — is a no-op. Queries keep running against the
337
+ * in-memory dag until the app replaces the instance (see
338
+ * `onClientStateNotFound`).
339
+ *
340
+ * Use together with {@link stopPersist} before dropping the database, so
341
+ * the run loop's refresh after a connect error does not run into the
342
+ * dropped store and log `database is closed` as an error.
343
+ */
344
+ stopRefresh(): Promise<void>;
317
345
  disableClientGroup(): Promise<void>;
318
346
  /**
319
347
  * Runs a refresh as soon as possible through the refresh scheduler.
@@ -1 +1 @@
1
- {"version":3,"file":"replicache-impl.d.ts","sourceRoot":"","sources":["../../../../replicache/src/replicache-impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAUjD,OAAO,KAA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AoLD,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAoB1C;IAED;;;;;;;OAOG;IACH,4BAA4B,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CAElE;CACF"}
@@ -174,15 +174,23 @@ var ReplicacheImpl = class {
174
174
  #zero;
175
175
  #closeAbortController = new AbortController();
176
176
  /**
177
- * Aborted on close AND on a storage failure after the open. The store-using
178
- * background processes (heartbeat, client and client-group GC, database
179
- * collection, mutation recovery, the new-client channel's store read) run
180
- * on this signal, so the first detected failure stops them instead of
181
- * letting each retry the fault at its interval and log `Error running.`
182
- * every time. A failure during the open moves the stores onto memory
183
- * instead, where they keep running.
177
+ * Aborted on close, on a storage failure after the open, and by
178
+ * {@link stopPersist}. `persist()`, the persist scheduler and the
179
+ * store-writing background processes (heartbeat, client and client-group
180
+ * GC, database collection, mutation recovery) stop on this signal, so the
181
+ * first detected failure stops them instead of letting each retry the
182
+ * fault at its interval and log `Error running.` every time. A failure
183
+ * during the open moves the stores onto memory instead, where they keep
184
+ * running.
184
185
  */
185
- #storeProcessesAbortController = new AbortController();
186
+ #persistAbortController = new AbortController();
187
+ /**
188
+ * Aborted on close, on a storage failure after the open, and by
189
+ * {@link stopRefresh}. `refresh()`, the refresh scheduler and the
190
+ * store-reading background process (the new-client channel's store read)
191
+ * stop on this signal.
192
+ */
193
+ #refreshAbortController = new AbortController();
186
194
  #persistLock = new Lock();
187
195
  #enableScheduledPersist;
188
196
  #enableScheduledRefresh;
@@ -277,6 +285,18 @@ var ReplicacheImpl = class {
277
285
  */
278
286
  #storageFailure;
279
287
  /**
288
+ * The last persist queued on the persist lock, if any, so
289
+ * {@link stopPersist} can wait for it. The lock runs persists in order, so
290
+ * this one settles after every persist queued before it. Settled to
291
+ * `undefined` rather than left rejected.
292
+ */
293
+ #persistInFlight;
294
+ /**
295
+ * The refresh currently running, if any, so {@link stopRefresh} can wait
296
+ * for it. Settled to `undefined` rather than left rejected.
297
+ */
298
+ #refreshInFlight;
299
+ /**
280
300
  * `onUpdateNeeded` is called when a code update is needed.
281
301
  *
282
302
  * A code update can be needed because:
@@ -328,7 +348,10 @@ var ReplicacheImpl = class {
328
348
  name,
329
349
  "replicache version": version
330
350
  });
331
- this.#closeAbortController.signal.addEventListener("abort", () => this.#storeProcessesAbortController.abort(), { once: true });
351
+ this.#closeAbortController.signal.addEventListener("abort", () => {
352
+ this.#persistAbortController.abort();
353
+ this.#refreshAbortController.abort();
354
+ }, { once: true });
332
355
  this.#subscriptions = new SubscriptionsManagerImpl(this.#queryInternal, this.#lc, this.#closeAbortController.signal);
333
356
  const kvStoreProvider = new MemFallbackStoreProvider(getKVStoreProvider(this.#lc, options.kvStore), (failure) => this.#onMemFallBack(failure), (failure) => this.#handleStorageFailure(failure));
334
357
  this.#kvStoreProvider = kvStoreProvider;
@@ -390,14 +413,14 @@ var ReplicacheImpl = class {
390
413
  this.pull().catch(noop);
391
414
  this.push().catch(noop);
392
415
  }
393
- const { signal } = this.#storeProcessesAbortController;
416
+ const { signal } = this.#persistAbortController;
394
417
  startHeartbeats(clientID, this.perdag, () => {
395
418
  this.#clientStateNotFoundOnClient(clientID);
396
419
  }, HEARTBEAT_INTERVAL, this.#lc, signal, this.#reportStorageFailure);
397
420
  initClientGC(clientID, this.perdag, clientMaxAgeMs, GC_INTERVAL, onClientsDeleted, this.#lc, signal, this.#reportStorageFailure);
398
421
  initCollectIDBDatabases(this.#idbDatabases, this.#kvStoreProvider, COLLECT_IDB_INTERVAL, INITIAL_COLLECT_IDB_DELAY, 2 * clientMaxAgeMs, enableMutationRecovery, onClientsDeleted, this.#lc, signal, (name, createKVStore) => new StoreImpl(createKVStore(name), newRandomHash, assertHash, name === this.idbName ? this.#onInvalidRefCount : void 0), this.#reportStorageFailure);
399
422
  initClientGroupGC(this.perdag, enableMutationRecovery, this.#lc, signal, this.#reportStorageFailure);
400
- initNewClientChannel(this.name, this.idbName, signal, client.clientGroupID, isNewClientGroup, () => {
423
+ initNewClientChannel(this.name, this.idbName, this.#refreshAbortController.signal, client.clientGroupID, isNewClientGroup, () => {
401
424
  this.#fireOnUpdateNeeded(updateNeededReasonNewClientGroup);
402
425
  }, this.perdag);
403
426
  setIntervalWithSignal(() => this.recoverMutations(), RECOVER_MUTATIONS_INTERVAL_MS, signal);
@@ -719,10 +742,10 @@ var ReplicacheImpl = class {
719
742
  };
720
743
  }
721
744
  persist() {
722
- return this.#persistLock.withLock(async () => {
745
+ const run = this.#persistLock.withLock(async () => {
723
746
  const { clientID } = this;
724
747
  await this.#ready;
725
- if (this.#closed || this.#storageFailure) return;
748
+ if (this.#closed || this.#storageFailure || this.#persistAbortController.signal.aborted) return;
726
749
  try {
727
750
  await persistDD31(this.#lc, clientID, this.memdag, this.perdag, this.#mutatorRegistry, () => this.#closed, 7, this.#zero?.getTxData);
728
751
  } catch (e) {
@@ -745,11 +768,18 @@ var ReplicacheImpl = class {
745
768
  clientGroupID
746
769
  });
747
770
  });
771
+ this.#persistInFlight = run.catch(noop);
772
+ return run;
748
773
  }
749
- async refresh() {
774
+ refresh() {
775
+ const run = this.#refresh();
776
+ this.#refreshInFlight = run.catch(noop);
777
+ return run;
778
+ }
779
+ async #refresh() {
750
780
  await this.#ready;
751
781
  const { clientID } = this;
752
- if (this.#closed || this.#storageFailure || !this.#enableRefresh()) return;
782
+ if (this.#closed || this.#storageFailure || this.#refreshAbortController.signal.aborted || !this.#enableRefresh()) return;
753
783
  let refreshResult;
754
784
  try {
755
785
  refreshResult = await refresh(this.#lc, this.memdag, this.perdag, clientID, this.#mutatorRegistry, this.#subscriptions, () => this.closed, 7, this.#zero);
@@ -797,7 +827,8 @@ var ReplicacheImpl = class {
797
827
  #handleStorageFailure(failure) {
798
828
  if (this.#storageFailure !== void 0) return;
799
829
  this.#storageFailure = failure;
800
- this.#storeProcessesAbortController.abort();
830
+ this.#persistAbortController.abort();
831
+ this.#refreshAbortController.abort();
801
832
  this.#lc.warn?.(`Local store storage failed (${failure.kind}) for ${this.idbName}; persistence is stopped for this instance`, failure);
802
833
  this.#fireOnStorageFailure(failure);
803
834
  }
@@ -891,6 +922,40 @@ var ReplicacheImpl = class {
891
922
  await this.disableClientGroup();
892
923
  this.#fireOnClientStateNotFound();
893
924
  }
925
+ /**
926
+ * Stops every write to the local store, for an instance whose database is
927
+ * about to be dropped from under it: the store-writing background
928
+ * processes (heartbeat, GC, collection, mutation recovery) are aborted, a
929
+ * `persist()` already in flight is waited for, and every later `persist()`
930
+ * — scheduled or explicit — is a no-op. Mutations keep running against the in-memory
931
+ * dag until the app replaces the instance (see `onClientStateNotFound`).
932
+ *
933
+ * Use together with {@link stopRefresh} before dropping the database, so
934
+ * the drop's own footprint — `database is closed` from the next scheduled
935
+ * persist and the background processes — is not logged as errors against a
936
+ * store that was deleted on purpose.
937
+ */
938
+ async stopPersist() {
939
+ this.#persistAbortController.abort();
940
+ await this.#persistInFlight;
941
+ }
942
+ /**
943
+ * Stops every refresh from the local store, for an instance whose database
944
+ * is about to be dropped from under it: the store-reading background
945
+ * process (the new-client channel) is aborted, a `refresh()` already in
946
+ * flight is waited for, and every later `refresh()` / `runRefresh()` —
947
+ * scheduled or explicit — is a no-op. Queries keep running against the
948
+ * in-memory dag until the app replaces the instance (see
949
+ * `onClientStateNotFound`).
950
+ *
951
+ * Use together with {@link stopPersist} before dropping the database, so
952
+ * the run loop's refresh after a connect error does not run into the
953
+ * dropped store and log `database is closed` as an error.
954
+ */
955
+ async stopRefresh() {
956
+ this.#refreshAbortController.abort();
957
+ await this.#refreshInFlight;
958
+ }
894
959
  async disableClientGroup() {
895
960
  const clientGroupID = await this.#clientGroupIDPromise;
896
961
  assert(clientGroupID, "Expected clientGroupID to be defined");
@@ -902,7 +967,7 @@ var ReplicacheImpl = class {
902
967
  this.onUpdateNeeded?.(reason);
903
968
  }
904
969
  async #schedulePersist() {
905
- if (!this.#enableScheduledPersist || this.#storageFailure) return;
970
+ if (!this.#enableScheduledPersist || this.#storageFailure || this.#persistAbortController.signal.aborted) return;
906
971
  await this.#schedule("persist", this.#persistScheduler);
907
972
  }
908
973
  async #handlePersist(persistInfo) {
@@ -911,7 +976,7 @@ var ReplicacheImpl = class {
911
976
  if (persistInfo.clientGroupID === clientGroupID) this.#scheduleRefresh();
912
977
  }
913
978
  async #scheduleRefresh() {
914
- if (!this.#enableScheduledRefresh || this.#storageFailure) return;
979
+ if (!this.#enableScheduledRefresh || this.#storageFailure || this.#refreshAbortController.signal.aborted) return;
915
980
  await this.#schedule("refresh from storage", this.#refreshScheduler);
916
981
  }
917
982
  async #schedule(name, scheduler) {
@@ -1070,7 +1135,7 @@ var ReplicacheImpl = class {
1070
1135
  return ex;
1071
1136
  }
1072
1137
  recoverMutations() {
1073
- if (this.#storeProcessesAbortController.signal.aborted) return promiseFalse;
1138
+ if (this.#persistAbortController.signal.aborted) return promiseFalse;
1074
1139
  }
1075
1140
  /**
1076
1141
  * List of pending mutations. The order of this is from oldest to newest.