Skip to content
Docs
Changelog

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.

Markdown

  • One module instead of nine hand-written copies. committed(db, work, { system, waitUntil }) in @fofo/db/committed opens 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 with unit.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 after hook. 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. admitWebBillingEvent and applyWebSnapshot returned 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.queuedAudits and platform/rpc/audit-flush.ts are gone, and createAuth(request, db, { unit }) replaces the onAuditQueued, onNotificationQueued, onObjectsReleased and onEmailFailed callbacks. recordAudit moved from @fofo/db/audit to @fofo/db/committed and joins an open unit. A feature that wrote db.transaction(...) plus finishQueuedAudits(...) writes committed(...) and unit.audit(...).
Edit on GitHubDocumentation is in English.
Cookie settings
We use essential cookies to make our app work. With your consent, we also use optional cookies to improve your experience.

Read our Cookie Policy and Privacy Policy.