diff --git a/src/backend/Database.ts b/src/backend/Database.ts index a26d25642..d05a4f82c 100644 --- a/src/backend/Database.ts +++ b/src/backend/Database.ts @@ -102,8 +102,15 @@ export class Database implements Syncable { return this.store.transaction(async tx => { const reHash = [] for (const mutation of mutations) { - const updateRows = await this.applyMutation(tx, mutation) - if (updateRows) reHash.push(updateRows) + try { + const updateRows = await this.applyMutation(tx, mutation) + if (updateRows) reHash.push(updateRows) + } catch (error) { + console.error(error) + console.warn( + `> could not apply mutation\n${JSON.stringify(mutation)}` + ) + } } await Database.index(tx) const changed = ( diff --git a/src/backend/Handler.ts b/src/backend/Handler.ts index 6eebe8166..201dc8b49 100644 --- a/src/backend/Handler.ts +++ b/src/backend/Handler.ts @@ -111,12 +111,17 @@ export class Handler { const {pending, db} = this.options const meta = await db.meta() if (!pending) return meta - const toApply = await pending.pendingSince( - meta.commitHash, - this.previewAuth() - ) - if (!toApply) return meta - await db.applyMutations(toApply.mutations, toApply.toCommitHash) + try { + const toApply = await pending.pendingSince( + meta.commitHash, + this.previewAuth() + ) + if (!toApply) return meta + await db.applyMutations(toApply.mutations, toApply.toCommitHash) + } catch (error) { + console.error(error) + console.warn('> could not sync pending mutations') + } return db.meta() } }