Do not emit error event if mutation was decided not to be rolled back by shouldRollback callback function (#52)

This commit is contained in:
Ewout Stortenbeker 2025-03-28 16:10:35 +01:00 committed by GitHub
parent 33ca750a1d
commit d8bcb4e15c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -327,7 +327,6 @@ export class LiveDataProxy {
.context(context)
[update.type](update.value) // .set or .update
.catch(async (err) => {
clientEventEmitter.emit('error', <ProxyObserveError>{ 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', <ProxyObserveError>{ 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') {