From d8bcb4e15c479b41ffeff25e585c86a02caff210 Mon Sep 17 00:00:00 2001 From: Ewout Stortenbeker Date: Fri, 28 Mar 2025 16:10:35 +0100 Subject: [PATCH] Do not emit error event if mutation was decided not to be rolled back by `shouldRollback` callback function (#52) --- src/data-proxy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-proxy.ts b/src/data-proxy.ts index fb7712a..8ca7793 100644 --- a/src/data-proxy.ts +++ b/src/data-proxy.ts @@ -327,7 +327,6 @@ export class LiveDataProxy { .context(context) [update.type](update.value) // .set or .update .catch(async (err) => { - clientEventEmitter.emit('error', { source: 'update', message: `Error processing update of "/${ref.path}"`, details: err }); // console.warn(`Proxy could not update DB, should rollback (${update.type}) the proxy value of "${update.ref.path}" to: `, update.previous); if (options?.shouldRollback) { const rollback = await options.shouldRollback(err, { type: update.type, ref: update.ref, value: update.value, previous: update.previous }); @@ -336,6 +335,7 @@ export class LiveDataProxy { return; } } + clientEventEmitter.emit('error', { source: 'update', message: `Error processing update of "/${ref.path}"`, details: err }); const context:IProxyContext = { acebase_proxy: { id: proxyId, source: 'update-rollback' } }; const mutations:IDataMutationsArray = []; if (update.type === 'set') {