Close payment-gateway render loop and repair gift-card/coupon submit - #804
Merged
Conversation
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).
gciotola
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 neworder/paymentSourceidentities 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 loopTwo regressions from the rapid-form v4 migration (#779):
Submit was a silent no-op for a non-required field. rapid-form v4's form-level auto-discovery only tracks fields that are
requiredor carry a validation config, so arequired={false}input — which is what mfe-checkout renders — leftvalues[type]undefined andhandleSubmitreturned early, issuing no API request.handleSubmitnow reads the typed code straight from the form DOM viaform.elements.namedItem, which is authoritative regardless of rapid-form wiring or timing. The form ref also passesresetOnSubmit: false, so rapid-form no longer attaches a native submit listener that wiped the input before React'sonSubmitran — the field is preserved on failure and cleared only by our ownform.reset()on success.The error-clearing effect looped. It re-dispatched a freshly filtered array every run; because
errorsis 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.0rather thanmain, which is the v4 line.🤖 Generated with Claude Code