You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(checkout): generate bills from a consistent order snapshot #254
Bill generation can use an order snapshot read before its transaction, allowing a concurrent order mutation to produce a bill that does not match the committed order totals.
Current behavior
main/routes/bills.ts:163-245 reads the order before acquiring the transaction and creates or synchronizes the bill from that object. Concurrent discount, item-add, or cancellation work can commit between the read and bill write.
Expected behavior
Bill generation must snapshot the authoritative order state atomically and preserve a consistent subtotal, tax, discount, and total relationship.
Acceptance criteria
Re-read or version-check the order inside the bill transaction.
Define behavior for concurrent item, discount, cancellation, and payment mutations.
Add concurrency tests asserting that the generated bill matches the committed order snapshot.
Preserve existing tax snapshot and rounding contracts.
Investigated against main at 241d6ca / FloCafe 3.0.5.
The reported race could not be reproduced. Bill generation does read the order before withTxn(), but the current runtime uses a single synchronous better-sqlite3 connection, with no event-loop yield between that read and the transaction. Concurrent HTTP mutation attempts were therefore serialized and did not produce a mixed bill/order snapshot.
Relevant existing suites also pass:
test:integration-reconciliation — 22/22
test:integration-payments — 33/33
test:integration-lifecycle — 18/18
Reading the order inside the transaction would be cleaner as defense-in-depth, but it does not fix a demonstrated production bug in the current architecture. If FloCafe later introduces async DB access, multiple writer connections, or multiple writer processes, transaction and locking semantics should be reviewed as part of that architecture change.
Closing as not reproducible under the current supported runtime.
Activity
khaira777 commentedon Aug 12, 2026
Investigated against
mainat241d6ca/ FloCafe 3.0.5.The reported race could not be reproduced. Bill generation does read the order before
withTxn(), but the current runtime uses a single synchronousbetter-sqlite3connection, with no event-loop yield between that read and the transaction. Concurrent HTTP mutation attempts were therefore serialized and did not produce a mixed bill/order snapshot.Relevant existing suites also pass:
test:integration-reconciliation— 22/22test:integration-payments— 33/33test:integration-lifecycle— 18/18Reading the order inside the transaction would be cleaner as defense-in-depth, but it does not fix a demonstrated production bug in the current architecture. If FloCafe later introduces async DB access, multiple writer connections, or multiple writer processes, transaction and locking semantics should be reviewed as part of that architecture change.
Closing as not reproducible under the current supported runtime.