http/pending_effects.ts view source
<T>(post_commit_effects: (() => void | Promise<void>)[] | undefined, dispatch: () => T | Promise<T>): Promise<Awaited<T>> import {dispatch_with_post_commit_rollback} from '@fuzdev/fuz_app/http/pending_effects.js'; Run a handler dispatch (the handler plus its wrapping db.transaction),
discarding any post_commit_effects it queued via emit_after_commit if it
throws. A thrown handler rolls back its transaction, so firing those deferred
effects would announce state that never committed. On any throw the queue is
truncated back to its pre-dispatch depth — not cleared, so entries a
surrounding scope pre-seeded survive — and the error re-thrown unchanged.
The eager pending_effects queue is deliberately never touched here: its
pool writes run outside the transaction and intentionally survive rollback
(attempt audits). emit_after_commit thus reads as "run iff the wrapping
transaction commits."
Both dispatch sites — the REST route wrapper (http/route_spec.ts) and the
action dispatcher (actions/perform_action.ts, the RPC + WS path) — wrap
their handler call in this so the discard contract lives in one place. The
Rust fuz_actions spine pins the same contract.
post_commit_effects is undefined when a handler runs without the
app-server pending-effects middleware (bare route / dispatch harnesses):
absent ⇒ nothing queued ⇒ nothing to discard.
post_commit_effects
the deferred queue to truncate on throw, or undefined
(() => void | Promise<void>)[] | undefineddispatch
invokes the handler (and any wrapping transaction)
() => T | Promise<T>returns
Promise<Awaited<T>>
generics
dispatch_with_post_commit_rollback<T>T
mutates
post_commit_effects— truncated to its pre-dispatch depth on throw