Skip to content

Commit 14cf21e

Browse files
kriszypclaude
andcommitted
fix: only record structure update after txn commits
Move `this.structureUpdate = structures` out of the transactionSync callback so it is only set on a confirmed commit. Setting it inside the callback left it dangling on an aborted txn, which could flag a spurious HAS_STRUCTURE_UPDATE in the audit log for a structure that was never persisted. Addresses review feedback. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent b24441c commit 14cf21e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

resources/RecordEncoder.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,18 @@ export class RecordEncoder extends StructonEncoder {
246246
return false;
247247
}
248248
txn.putSync(sharedStructuresKey, structures);
249-
this.structureUpdate = structures;
250249
return true;
251250
},
252251
{ retryOnBusy: true }
253252
);
254-
return committed === true ? true : false;
253+
// Only record the structure update once the txn has actually committed. Setting it
254+
// inside the callback would leave it dangling on an aborted txn and could flag a
255+
// HAS_STRUCTURE_UPDATE in the audit log for a structure that was never persisted.
256+
if (committed === true) {
257+
this.structureUpdate = structures;
258+
return true;
259+
}
260+
return false;
255261
} else {
256262
const result = superSaveStructures.call(this, structures, isCompatible);
257263
this.structureUpdate = structures;

0 commit comments

Comments
 (0)