Commit transaction before fetching cart-mini fragment
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s

The cart-mini fragment is fetched via HTTP from the cart app, which
uses its own DB connection. Without committing first, the cart app
sees stale data (no new item). Commit the transaction, start a new
one so after_request can still commit cleanly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-24 10:55:40 +00:00
parent 06e700820e
commit 93f830ff13

View File

@@ -254,6 +254,10 @@ def register():
# htmx response: OOB-swap mini cart + product buttons
if request.headers.get("HX-Request") == "true":
# Commit so the cart app sees the updated data when we fetch the fragment
await g.tx.commit()
g.tx = await g.s.begin()
from shared.infrastructure.fragments import fetch_fragment
from shared.infrastructure.cart_identity import current_cart_identity as _ci
frag_ident = _ci()