- One module instead of nine hand-written copies.
committed(db, work, { system, waitUntil })in@fofo/db/committedopens a transaction, collects what the work registers on its unit (unit.audit,unit.afterCommit) and runs each effect once after COMMIT. A unit that rolls back, or that is aborted withunit.abort(reason), runs nothing, even when the callback catches a statement failure and returns. A unit opened inside another one waits for the outer COMMIT. The Better Auth handler, the admin API,withAudit, the sensitive-data guard, both tool approval paths and the billing writers use it. See backend conventions. (#252) - Fixed: an admin write behaved differently from the same change made by the User. When an admin removed a User, their feedback images were deleted through the request's storage handle instead of the one a self-service deletion uses, and a failed deletion was not logged. A notification email queued by a Better Auth hook during an admin write would have been sent before the write committed, so also for a write that then failed. All three now follow the one protocol: same storage handle, failures logged, emails after COMMIT only.
- Fixed: four Audit Events were written without being awaited. Two-factor, passkey, Org role and admin events were queued by a floating promise in Better Auth's
afterhook. They are awaited now, like every other event, so a failed write of the event fails the request instead of leaving a change without its event. - Billing writers flush nothing by hand.
admitWebBillingEventandapplyWebSnapshotreturned audit ids for their four callers to move to history; the unit moves the event after COMMIT inside the writer, and the callers lost that step. - For template users.
Context.queuedAuditsandplatform/rpc/audit-flush.tsare gone, andcreateAuth(request, db, { unit })replaces theonAuditQueued,onNotificationQueued,onObjectsReleasedandonEmailFailedcallbacks.recordAuditmoved from@fofo/db/auditto@fofo/db/committedand joins an open unit. A feature that wrotedb.transaction(...)plusfinishQueuedAudits(...)writescommitted(...)andunit.audit(...).
One unit of work runs what follows a write
Audit Event history, storage deletes and emails that follow a write are registered on one committed-transaction module and run once after COMMIT. Three differences between the admin path and the sign-in path are gone.
Edit on GitHubDocumentation is in English.