Skip to content

Close payment-gateway render loop and repair gift-card/coupon submit - #804

Merged
acasazza merged 2 commits into
v5.0.0from
fix/803-payment-gateway-mismatched-loop
Jul 29, 2026
Merged

Close payment-gateway render loop and repair gift-card/coupon submit#804
acasazza merged 2 commits into
v5.0.0from
fix/803-payment-gateway-mismatched-loop

Conversation

@acasazza

Copy link
Copy Markdown
Member

Two independent render/no-op bugs, both surfacing in mfe-checkout.

PaymentGateway — single-method mismatched-amounts render loop (#803)

The payment-source reconcile effect is reworked around a useEffectEvent, so its dependency array is a deliberate trigger set of stable ids and scalars rather than whole objects. Customer-source refetches that mint new order / paymentSource identities no longer re-fire it.

The single-payment-method branch now recreates a source when it is mismatched, not only when absent or errored, and refetches customer sources only after a real (re)create — so a no-op pass cannot re-arm the loop.

The three load-bearing invariants are written up in ADR 0001, with regression coverage for the mismatched-amounts reproduction and the no-op-pass guard.

GiftCardOrCouponForm — submit no-op and error-clear loop

Two regressions from the rapid-form v4 migration (#779):

  1. Submit was a silent no-op for a non-required field. rapid-form v4's form-level auto-discovery only tracks fields that are required or carry a validation config, so a required={false} input — which is what mfe-checkout renders — left values[type] undefined and handleSubmit returned early, issuing no API request. handleSubmit now reads the typed code straight from the form DOM via form.elements.namedItem, which is authoritative regardless of rapid-form wiring or timing. The form ref also passes resetOnSubmit: false, so rapid-form no longer attaches a native submit listener that wiped the input before React's onSubmit ran — the field is preserved on failure and cleared only by our own form.reset() on success.

  2. The error-clearing effect looped. It re-dispatched a freshly filtered array every run; because errors is a dependency, the new reference re-fired the effect indefinitely (React 19 "Maximum update depth exceeded"). It now bails when filtering changes nothing, so it converges.

Adds GiftCardOrCouponForm.integration.spec.tsx, which exercises the real rapid-form wiring — the pre-existing spec mocks rapid-form, which is what hid both bugs.

Notes

Targets v5.0.0 rather than main, which is the v4 line.

🤖 Generated with Claude Code

Alessandro Casazza added 2 commits July 24, 2026 16:08
…oop (#803)

Reworks the payment-source reconcile effect around a useEffectEvent so its
dependency array is a deliberate trigger set of stable ids/scalars, never whole
objects — customer-source refetches that mint new order/paymentSource identities
no longer re-fire the effect. The single-payment-method branch now recreates a
source when it is mismatched (not only absent/errored) and refetches customer
sources only after a real (re)create, so a no-op pass can never re-arm the loop.

Documents the three load-bearing invariants in ADR 0001 and adds regression
coverage for the mismatched-amounts reproduction and the no-op-pass guard.
Two regressions from the rapid-form v4 migration (#779), both in
GiftCardOrCouponForm:

1. Submit was a silent no-op for a non-required field. rapid-form v4's
   form-level auto-discovery only tracks a field that is `required` or has a
   validation config, so a `required={false}` input (as mfe-checkout renders)
   left `values[type]` undefined and handleSubmit returned early — no API
   request. handleSubmit now reads the typed code straight from the form DOM
   (form.elements.namedItem), which is authoritative regardless of rapid-form
   wiring or timing. The form ref also passes `resetOnSubmit: false` so
   rapid-form no longer attaches a native submit listener that reset the input
   before React's onSubmit ran; the field is now preserved on failure and
   cleared only by our own form.reset() on success. A pass-through validation
   keeps values populated for the error-clearing effect.

2. The error-clearing effect looped. It re-dispatched a fresh filtered array
   every run; since `errors` is a dependency, the new reference re-fired the
   effect indefinitely (React 19 "Maximum update depth exceeded"). It now bails
   when filtering changes nothing, so it converges.

Adds GiftCardOrCouponForm.integration.spec.tsx exercising the real rapid-form
wiring (the existing spec mocks it, which hid both bugs).
@malessani malessani changed the title fix: close payment-gateway render loop and repair gift-card/coupon submit Close payment-gateway render loop and repair gift-card/coupon submit Jul 29, 2026
@acasazza
acasazza merged commit 83e98f7 into v5.0.0 Jul 29, 2026
2 checks passed
@acasazza
acasazza deleted the fix/803-payment-gateway-mismatched-loop branch July 29, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants