From 93f830ff13d1dad5736f3e6d17e85fd1b0d176f8 Mon Sep 17 00:00:00 2001 From: giles Date: Tue, 24 Feb 2026 10:55:40 +0000 Subject: [PATCH] Commit transaction before fetching cart-mini fragment 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 --- bp/product/routes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bp/product/routes.py b/bp/product/routes.py index 4ea209a..ce17917 100644 --- a/bp/product/routes.py +++ b/bp/product/routes.py @@ -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()