Rename & make idempotent

This commit is contained in:
Andras Schmelczer 2025-03-20 21:19:41 +00:00
commit 136514d33a
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -114,7 +114,7 @@ export class Database {
this.save(); this.save();
} }
public resetSyncState(): void { public reset(): void {
this.documents = []; this.documents = [];
this.lastSeenUpdateId = 0; this.lastSeenUpdateId = 0;
this.save(); this.save();
@ -142,7 +142,9 @@ export class Database {
); );
if (entry === undefined) { 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); entry.updates = entry.updates.filter((update) => update !== promise);