From 9110f474c5a8abf13c2faff58a60babadd005d6c Mon Sep 17 00:00:00 2001 From: Ewout Stortenbeker Date: Tue, 11 Apr 2023 20:42:25 +0200 Subject: [PATCH] Transaction logging fixes: - use IPC settings - catch `getMutations` node not found error if there are no mutations --- src/storage/binary/index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/storage/binary/index.ts b/src/storage/binary/index.ts index e3129e9..cf88215 100644 --- a/src/storage/binary/index.ts +++ b/src/storage/binary/index.ts @@ -143,7 +143,7 @@ export class AceBaseStorage extends Storage { this.type = settings.type; if (this.type === 'data' && settings.transactions.log === true) { // Get/create storage for mutations logging - const txSettings = new AceBaseStorageSettings({ type: 'transaction', path: settings.path, removeVoidProperties: true, transactions: settings.transactions }); + const txSettings = new AceBaseStorageSettings({ type: 'transaction', path: settings.path, removeVoidProperties: true, transactions: settings.transactions, ipc: settings.ipc }); this.txStorage = new AceBaseStorage(name, txSettings, { logLevel: 'error' }); } @@ -1576,18 +1576,24 @@ export class AceBaseStorage extends Storage { let count = 0; const oldestValidCursor = this.oldestValidCursor, expiredTransactions: string[] = [], inspectFurther: string[] = []; - await this.getChildren('history', { tid }) - .next(childInfo => { + try { + await this.getChildren('history', { tid }).next(childInfo => { const txCursor = childInfo.key.slice(0, cursor.length); if (txCursor < oldestValidCursor) { expiredTransactions.push(childInfo.key); } if (txCursor < cursor) { return; } if (txCursor === cursor) { - // cuid timestamp bytes are equal - perform extra check on this mutation later to find out if we have to include it in the results + // cuid timestamp bytes are equal - perform extra check on this mutation later to find out if we have to include it in the results inspectFurther.push(childInfo.key); } count++; check(childInfo.key); }); + } + catch (err) { + if (!(err instanceof NodeNotFoundError)) { + throw err; + } + } allEnumerated = true; if (count > 0) {