@automerge/automerge-repo
Advanced tools
Comparing version 2.0.0-alpha.5 to 2.0.0-alpha.6
@@ -181,4 +181,10 @@ import * as A from "@automerge/automerge/slim/next"; | ||
const key = [documentId, "sync-state", storageId]; | ||
const loaded = await this.#storageAdapter.load(key); | ||
return loaded ? A.decodeSyncState(loaded) : undefined; | ||
try { | ||
const loaded = await this.#storageAdapter.load(key); | ||
return loaded ? A.decodeSyncState(loaded) : undefined; | ||
} | ||
catch (e) { | ||
this.#log(`Error loading sync state for ${documentId} from ${storageId}`); | ||
return undefined; | ||
} | ||
} | ||
@@ -185,0 +191,0 @@ async saveSyncState(documentId, storageId, syncState) { |
{ | ||
"name": "@automerge/automerge-repo", | ||
"version": "2.0.0-alpha.5", | ||
"version": "2.0.0-alpha.6", | ||
"description": "A repository object to manage a collection of automerge documents", | ||
@@ -63,3 +63,3 @@ "repository": "https://github.com/automerge/automerge-repo/tree/master/packages/automerge-repo", | ||
}, | ||
"gitHead": "9f10cdceb172f92cdf2dc1be361a940dfd3c5858" | ||
"gitHead": "87353a94d2e5d8facc1db359d9e6fa74e2ab8888" | ||
} |
@@ -235,4 +235,9 @@ import * as A from "@automerge/automerge/slim/next" | ||
const key = [documentId, "sync-state", storageId] | ||
const loaded = await this.#storageAdapter.load(key) | ||
return loaded ? A.decodeSyncState(loaded) : undefined | ||
try { | ||
const loaded = await this.#storageAdapter.load(key) | ||
return loaded ? A.decodeSyncState(loaded) : undefined | ||
} catch (e) { | ||
this.#log(`Error loading sync state for ${documentId} from ${storageId}`) | ||
return undefined | ||
} | ||
} | ||
@@ -239,0 +244,0 @@ |
@@ -214,2 +214,19 @@ import { NodeFSStorageAdapter } from "../../automerge-repo-storage-nodefs/src/index.js" | ||
}) | ||
it("returns a undefined if loading an existing sync state fails", async () => { | ||
const storage = new StorageSubsystem(adapter) | ||
const { documentId } = parseAutomergeUrl(generateAutomergeUrl()) | ||
const bobStorageId = Uuid.v4() as StorageId | ||
const syncStateKey = [documentId, "sync-state", bobStorageId] | ||
// Save garbage data to simulate a corrupted sync state | ||
await adapter.save(syncStateKey, Buffer.from("invalid data")) | ||
const loadedSyncState = await storage.loadSyncState( | ||
documentId, | ||
bobStorageId | ||
) | ||
assert.strictEqual(loadedSyncState, undefined) | ||
}) | ||
}) | ||
@@ -216,0 +233,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
443896
10267