From 136514d33a7b2aa891af76983ad070a6dbd9276c Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Thu, 20 Mar 2025 21:19:41 +0000 Subject: [PATCH] Rename & make idempotent --- frontend/sync-client/src/persistence/database.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/sync-client/src/persistence/database.ts b/frontend/sync-client/src/persistence/database.ts index 9f003d4c..c2f12234 100644 --- a/frontend/sync-client/src/persistence/database.ts +++ b/frontend/sync-client/src/persistence/database.ts @@ -114,7 +114,7 @@ export class Database { this.save(); } - public resetSyncState(): void { + public reset(): void { this.documents = []; this.lastSeenUpdateId = 0; this.save(); @@ -142,7 +142,9 @@ export class Database { ); if (entry === undefined) { - throw new Error("Document not found by update promise"); + // This method should be idempotent and tolerant of + // stragglers calling it after the databse has been reset. + return; } entry.updates = entry.updates.filter((update) => update !== promise);