@evolu/common 8.17.0 → 8.19.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.
Files changed (48) hide show
  1. package/dist/src/Bytes.d.ts +31 -14
  2. package/dist/src/Bytes.d.ts.map +1 -1
  3. package/dist/src/Bytes.js +48 -8
  4. package/dist/src/Error.d.ts.map +1 -1
  5. package/dist/src/Error.js +5 -1
  6. package/dist/src/Polyfills.d.ts.map +1 -1
  7. package/dist/src/Polyfills.js +3 -2
  8. package/dist/src/Sqlite.d.ts +1 -1
  9. package/dist/src/Task.d.ts +4 -3
  10. package/dist/src/Task.d.ts.map +1 -1
  11. package/dist/src/Task.js +4 -3
  12. package/dist/src/index.d.ts +1 -1
  13. package/dist/src/index.d.ts.map +1 -1
  14. package/dist/src/local-first/Db.d.ts +32 -3
  15. package/dist/src/local-first/Db.d.ts.map +1 -1
  16. package/dist/src/local-first/Db.js +30 -9
  17. package/dist/src/local-first/Evolu.d.ts +21 -6
  18. package/dist/src/local-first/Evolu.d.ts.map +1 -1
  19. package/dist/src/local-first/Evolu.js +5 -1
  20. package/dist/src/local-first/Protocol.d.ts +215 -93
  21. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  22. package/dist/src/local-first/Protocol.js +799 -489
  23. package/dist/src/local-first/Relay.d.ts +9 -1
  24. package/dist/src/local-first/Relay.d.ts.map +1 -1
  25. package/dist/src/local-first/Relay.js +41 -36
  26. package/dist/src/local-first/Shared.d.ts +79 -53
  27. package/dist/src/local-first/Shared.d.ts.map +1 -1
  28. package/dist/src/local-first/Shared.js +67 -42
  29. package/dist/src/local-first/Storage.d.ts +80 -18
  30. package/dist/src/local-first/Storage.d.ts.map +1 -1
  31. package/dist/src/local-first/Storage.js +20 -4
  32. package/package.json +1 -1
  33. package/src/Bytes.test.ts +212 -0
  34. package/src/Bytes.ts +67 -17
  35. package/src/Error.ts +5 -1
  36. package/src/Polyfills.ts +3 -2
  37. package/src/Sqlite.ts +1 -1
  38. package/src/Task.ts +4 -3
  39. package/src/index.ts +4 -1
  40. package/src/local-first/Db.ts +76 -17
  41. package/src/local-first/Evolu.test.ts +43 -12
  42. package/src/local-first/Evolu.ts +34 -7
  43. package/src/local-first/Protocol.test.ts +1541 -44
  44. package/src/local-first/Protocol.ts +1070 -605
  45. package/src/local-first/Relay.ts +80 -69
  46. package/src/local-first/Shared.test.ts +37 -1
  47. package/src/local-first/Shared.ts +124 -73
  48. package/src/local-first/Storage.ts +100 -27
@@ -23,8 +23,10 @@
23
23
  * version 1. A newer stored version refuses startup with
24
24
  * {@link UnsupportedDbVersionError}. The refusal returns from the startup
25
25
  * transaction before anything is written and is posted to the SharedWorker; the
26
- * worker then exits and releases its resources. The single version row is
27
- * created in the same transaction as the other system tables.
26
+ * worker then exits and releases its resources. A database whose files another
27
+ * context keeps holding refuses startup the same way, before it is opened, with
28
+ * {@link DatabaseHeldError}; see {@link WaitForDatabaseRelease}. The single
29
+ * version row is created in the same transaction as the other system tables.
28
30
  *
29
31
  * Code released before the version record existed never reads it. It recognizes
30
32
  * an initialized database by the `evolu_version` table alone, so it opens a
@@ -92,7 +94,7 @@ import { appendToArray, firstInArray, isNonEmptyArray, } from "../Array.js";
92
94
  import { assert, assertNonEmptyReadonlyArray, assertNonNullable, assertNotUndefined, } from "../Assert.js";
93
95
  import { EncryptionKey, } from "../Crypto.js";
94
96
  import { createUnknownError } from "../Error.js";
95
- import { constFalse, constVoid } from "../Function.js";
97
+ import { constFalse } from "../Function.js";
96
98
  import { acquireLeaderLock, acquireLeaderLockCallback, } from "../LockManager.js";
97
99
  import { createMutableRecord, getOwnProp, objectToEntries } from "../Object.js";
98
100
  import { err, getOk, ok, trySync } from "../Result.js";
@@ -135,6 +137,14 @@ export const startDbWorker = (self) => async (run) => {
135
137
  postConsoleEntry(consoleEntryOrErrorBroadcastChannel, entry);
136
138
  }));
137
139
  disposer.use(await run.ok(acquireLeaderLock(initMessage.name)));
140
+ if (!initMessage.memoryOnly && deps.waitForDatabaseRelease) {
141
+ const released = await run(deps.waitForDatabaseRelease(initMessage.name));
142
+ if (!released.ok) {
143
+ // Returning lets the disposer release the database lock.
144
+ port.postMessage({ type: "LeaderRefused", error: released.error });
145
+ return ok();
146
+ }
147
+ }
138
148
  const sqlite = disposer.use(await run.ok(createSqlite(initMessage.name, initMessage.memoryOnly
139
149
  ? { mode: "memory" }
140
150
  : { mode: "encrypted", encryptionKey: initMessage.encryptionKey })));
@@ -229,6 +239,7 @@ export const startDbWorker = (self) => async (run) => {
229
239
  storage.setRequestContext(owner.encryptionKey, context);
230
240
  const result = await run.abortable(applyProtocolMessageAsClient(inputMessage, {
231
241
  writeKey: owner.writeKey,
242
+ onChangeTooLarge: storage.onChangeTooLarge,
232
243
  }));
233
244
  postQueuedResponse({
234
245
  type: "ForSharedWorker",
@@ -312,7 +323,8 @@ export const startDbWorker = (self) => async (run) => {
312
323
  };
313
324
  // Stops once the SharedWorker no longer leads for its ID, which the
314
325
  // platform releases when it closes, because Firefox can lose a Dispose
315
- // posted right before that.
326
+ // posted right before that
327
+ // (https://bugzilla.mozilla.org/show_bug.cgi?id=2077609).
316
328
  const sharedWorkerEnded = acquireLeaderLockCallback(deps)(initMessage.sharedWorkerId, () => resolve(ok()));
317
329
  return () => {
318
330
  port.onMessage = null;
@@ -676,9 +688,11 @@ const createClientStorage = (deps) => {
676
688
  },
677
689
  didWriteMessages: () => didWriteMessages,
678
690
  skippedError: () => skippedError,
691
+ onChangeTooLarge: (error) => {
692
+ skippedError ??= error;
693
+ },
679
694
  // Not implemented yet.
680
695
  validateWriteKey: constFalse,
681
- setWriteKey: constVoid,
682
696
  writeMessages: (ownerIdBytes, encryptedMessages) => () => {
683
697
  // TODO: Add quota checking for collaborative scenarios.
684
698
  // When receiving messages from other owners via relay broadcast,
@@ -731,10 +745,17 @@ const createClientStorage = (deps) => {
731
745
  clockTimestamp = nextTimestamp.value;
732
746
  }
733
747
  let wroteNewMessages = false;
734
- deps.sqlite.transaction(() => {
735
- wroteNewMessages = applyMessages(deps)(ownerIdBytesToOwnerId(ownerIdBytes), messages, QuarantineOrigin.ReceivedMessage, now);
736
- saveClock(deps)(clockTimestamp);
737
- });
748
+ // SQLite can fail the write, for example on a full disk. The transaction
749
+ // has rolled back, so the route reports the error instead of a throw
750
+ // panicking the DbWorker.
751
+ const written = trySync(() => {
752
+ deps.sqlite.transaction(() => {
753
+ wroteNewMessages = applyMessages(deps)(ownerIdBytesToOwnerId(ownerIdBytes), messages, QuarantineOrigin.ReceivedMessage, now);
754
+ saveClock(deps)(clockTimestamp);
755
+ });
756
+ }, createUnknownError);
757
+ if (!written.ok)
758
+ return written;
738
759
  clock.set(clockTimestamp);
739
760
  // A batch of duplicates changes no table, so queries need no refresh.
740
761
  if (wroteNewMessages)
@@ -12,7 +12,7 @@ import type { Listener, ReadonlyStore, Unsubscribe } from "../Store.ts";
12
12
  import type { Task } from "../Task.ts";
13
13
  import { Name, PositiveInt, type TypeError, UrlSafeString } from "../Type.ts";
14
14
  import type { CreateBroadcastChannelDep, CreateMessageChannelDep } from "../Worker.ts";
15
- import type { CreateDbWorkerDep, UnsupportedDbVersionError } from "./Db.ts";
15
+ import type { CreateDbWorkerDep, DatabaseHeldError, UnsupportedDbVersionError } from "./Db.ts";
16
16
  import type { AppOwner, Owner, OwnerId, OwnerTransport, ReadonlyOwner } from "./Owner.ts";
17
17
  import type { Queries, QueriesToQueryRowsPromises, Query, QueryRows, Row } from "./Query.ts";
18
18
  import type { EvoluSchema, IndexesConfig, Mutation, MutationValues, ValidateSchema } from "./Schema.ts";
@@ -794,6 +794,9 @@ export type DevicePersistence = "Persisted" | "NotPersisted" | "Unknown";
794
794
  *
795
795
  * - {@link UnsupportedDbVersionError} blocks the app: the local data needs a newer
796
796
  * version of it. Ask the user to update the app or close all its tabs.
797
+ * - {@link DatabaseHeldError} blocks the app: another context keeps holding the
798
+ * local data, as a browser can until it restarts. Ask the user to close the
799
+ * app's other tabs or to restart the browser, then to reload the app.
797
800
  * - {@link OtherBuildRunningError} blocks the app while it lasts: another version
798
801
  * of the app holds the local data. Ask the user to close the app's other
799
802
  * tabs. It clears when the wait ends.
@@ -808,7 +811,8 @@ export type DevicePersistence = "Persisted" | "NotPersisted" | "Unknown";
808
811
  * request, or sent a frame that could not be decoded, the route shows a
809
812
  * {@link ProtocolError}. A {@link ProtocolQuotaError} needs more relay quota,
810
813
  * then {@link Evolu.requestSync}, and a {@link ProtocolVersionError} needs an app
811
- * or relay update.
814
+ * or relay update. A route shows an {@link UnknownError} failure when this
815
+ * device could not store received changes, for example on a full disk.
812
816
  *
813
817
  * A received change that was not created with the owner's encryption key, was
814
818
  * altered afterwards, or cannot be decoded by this app version is skipped,
@@ -833,9 +837,17 @@ export type DevicePersistence = "Persisted" | "NotPersisted" | "Unknown";
833
837
  * {@link DecryptWithXChaCha20Poly1305Error} and your code creates or shares the
834
838
  * owner, check the owner's keys.
835
839
  *
840
+ * A {@link ProtocolChangeTooLargeError} skip is a change no protocol message can
841
+ * hold: one this device saved before {@link maxMutationSize} existed, or a
842
+ * crafted one received from a relay. Every route through a relay that lacks it
843
+ * shows it after each sync, and everything else still syncs, but changes
844
+ * received from one relay reach the others only after a reconnect or
845
+ * {@link Evolu.requestSync}. The change is not recovered, and replacing relays
846
+ * does not help.
847
+ *
836
848
  * @group Core
837
849
  */
838
- export type EvoluError = OtherBuildRunningError | UnknownError | UnsupportedDbVersionError;
850
+ export type EvoluError = DatabaseHeldError | OtherBuildRunningError | UnknownError | UnsupportedDbVersionError;
839
851
  /**
840
852
  * The largest {@link Mutation}, in bytes.
841
853
  *
@@ -872,9 +884,10 @@ export interface EvoluErrorDep {
872
884
  * refusal to each tab once, including tabs that connect later, and starts no
873
885
  * replacement database workers. After all instances release that tenant and
874
886
  * it is disposed when idle, creating another instance retries startup and may
875
- * send the refusal again. On the web, a refused tab first reloads once
876
- * instead; see {@link UnsupportedDbVersionError}. Show that blocking message
877
- * outside any query-loading boundary, so pending queries do not hide it.
887
+ * send the refusal again. On the web, a tab refused with
888
+ * {@link UnsupportedDbVersionError} first reloads once instead. Show that
889
+ * blocking message outside any query-loading boundary, so pending queries do
890
+ * not hide it.
878
891
  *
879
892
  * An {@link UnknownError} leaves Evolu in an unknown state, so the app can
880
893
  * only ask the user to close the tab. A failed shared worker closes itself,
@@ -899,6 +912,8 @@ export interface EvoluErrorDep {
899
912
  * switch (error.type) {
900
913
  * case "UnsupportedDbVersionError":
901
914
  * return "Your data requires a newer version of this app. Please update it.";
915
+ * case "DatabaseHeldError":
916
+ * return "Your data is still in use elsewhere. Close this app's other tabs or restart the browser, then reload this page.";
902
917
  * case "OtherBuildRunningError":
903
918
  * return "This app is open in another tab with a different version. Close that tab to continue.";
904
919
  * case "UnknownError":
@@ -1 +1 @@
1
- {"version":3,"file":"Evolu.d.ts","sourceRoot":"","sources":["../../../src/local-first/Evolu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAS3B,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AASjE,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAML,IAAI,EACJ,WAAW,EACX,KAAK,SAAS,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAEV,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAC5E,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AACH,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAC/C,yBAAyB,GACzB,uBAAuB,GACvB,cAAc,GACd,YAAY,GACZ,eAAe,GACf,OAAO,CAAC,UAAU,CAAC,GACnB,OAAO,CAAC,YAAY,CAAC,GACrB,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,SAAU,iBAAiB,KAAG,SA4HzD,CAAC;AAUF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACrB,CAAC,SAAS,WAAW,UACZ,cAAc,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,UACvD,WAAW,KAClB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,CA6hBzC,CAAC"}
@@ -496,7 +496,11 @@ export const createEvolu = (schema, config) => async (run) => {
496
496
  // gets it already batched and cannot reach the call site; quarantine,
497
497
  // which holds changes stored for sync; and skipping it in sync, which
498
498
  // keeps range fingerprints disagreeing. Received changes are not
499
- // checked, and oversized changes stored before this limit are not
499
+ // checked. Changes saved before this limit can be too large for any
500
+ // protocol message, as can crafted changes on a relay. Their
501
+ // fingerprints disagree either way, so sync skips them, which ends
502
+ // every round instead of retrying forever. A client reports such a
503
+ // change as its route's skippedError, and a relay logs it. They are not
500
504
  // recovered, which needs a history-aware design.
501
505
  //
502
506
  // Local-only tables never sync, so they have no limit.