Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(client): retry failed snapshots with backoff instead of the debounce timer
Elian Dorana8a71fabbd83
diff --git a/apps/client/src/services/spaced_update.spec.ts b/apps/client/src/services/spaced_update.spec.tsindex c7aeb28825..e5926442cb 100644--- a/apps/client/src/services/spaced_update.spec.ts+++ b/apps/client/src/services/spaced_update.spec.ts@@ -353,7 +353,7 @@ describe("SpacedUpdate", () => {expect(commits).toEqual([{ key: "A", data: "typed into A" }]);});- it("re-arms the debounce timer when an asynchronous snapshot rejects, so the change is not stranded", async () => {+ it("schedules a retry when an asynchronous snapshot rejects, so the change is not stranded", async () => {let rejectPrepare: (e: Error) => void = () => {};const commits: { key: string; data: string }[] = [];const spacedUpdate = new SpacedUpdate<string>({diff --git a/apps/client/src/services/spaced_update.ts b/apps/client/src/services/spaced_update.tsindex ae90f9656e..fe71e0d993 100644--- a/apps/client/src/services/spaced_update.ts+++ b/apps/client/src/services/spaced_update.ts@@ -208,9 +208,10 @@ export default class SpacedUpdate<T = void> {this.changed = true;this.onStateChanged("error");// The debounce timer may have already fired and gone idle while the snapshot was- // being captured; re-arm it so the restored change is retried instead of being- // stranded until the next scheduleUpdate() call.- this.armDebounceTimer();+ // being captured; schedule a retry so the restored change is not stranded until+ // the next scheduleUpdate() call. Going through the retry timer (rather than the+ // debounce timer) gives persistent prepare() failures exponential backoff.+ this.scheduleRetry();throw e;};