Skip to content

Field sync controller - #1429

Draft
pbennett1-godaddy wants to merge 4 commits into
mainfrom
field-sync-controller
Draft

Field sync controller#1429
pbennett1-godaddy wants to merge 4 commits into
mainfrom
field-sync-controller

Conversation

@pbennett1-godaddy

Copy link
Copy Markdown
Contributor

Summary

This PR fixes checkout race conditions where a customer could click confirm/pay before debounced draft-order field syncs had completed. In those cases, checkout confirmation could run against a stale
draft order and miss recent form edits such as contact info, names, notes, shipping/billing addresses, phone values, or fulfillment-related order updates.

The main change centralizes draft-order field syncing behind a registration-based sync controller. Before confirmation, checkout now drains queued work, waits for critical checkout mutations/fetches,
rebuilds a final patch from the latest form values, sends it when needed, refetches the updated draft order, and only then confirms checkout.

This PR also tightens validation behavior for checkoutFormSchema so custom schema rules are enforced for fields the current checkout flow actually collects, without blocking checkout on
hidden/uncollectable fields. For example, a custom-required shippingAddressLine2 does not block a pickup checkout where shipping fields are hidden, and a custom-required phone field does not block
checkout when phone collection is disabled.

Changeset

  • Changeset added (docs)

Test Plan

Validated with targeted unit/integration tests and package checks:

pnpm --filter @godaddy/react test -- src/components/checkout/__tests__/checkout-draft-order-sync.test.tsx src/components/checkout/__tests__/checkout-form-validation.test.tsx                           
pnpm --filter @godaddy/react test -- src/components/checkout/__tests__/checkout-form-validation.test.tsx                                                                                                
pnpm --filter @godaddy/react test -- src/components/checkout/__tests__/checkout-draft-order-sync.test.tsx                                                                                               
pnpm --filter @godaddy/react typecheck                                                                                                                                                                  
pnpm --filter @godaddy/react lint                                                                                                                                                                       
git diff --check                                                                                                                                                                                        

Covered scenarios include:

  • Confirming checkout immediately after editing notes still syncs notes before confirmation.
  • Confirming checkout immediately after editing shipping names still syncs names before confirmation.
  • Confirming free pickup immediately after editing billing names still syncs names before confirmation.
  • Final checkout sync runs before ConfirmCheckoutSession.
  • Draft order is refetched after a final sync patch and before confirmation.
  • Confirmation is blocked and a checkout sync error is surfaced if final draft-order sync fails.
  • Duplicate confirmation attempts are blocked while the first confirm is in flight.
  • Existing normal background order sync flows still work for contact email, address, phone, names, and notes.
  • Invalid email/phone values do not sync to the draft order until corrected.
  • Failed queued registration patches are rebuilt with corrected current form values instead of retrying stale rejected values.
  • Partial name edits are not marked pristine by address-only syncs and survive draft-order refetch hydration.
  • Custom schema validation is enforced for collectable fields skipped by built-in conditional validation, such as required billingPhone in free pickup when phone collection is enabled.
  • Custom schema validation does not block checkout for hidden/uncollectable fields, including:
    • phone fields when enablePhoneCollection is false
    • shipping fields when pickup is selected
    • billing address fields when billing address is hidden because shipping address is reused
  • Shipping/pickup selection remains stable across draft-order refetches during sync flows.
  • Address-only changes still trigger taxes/rates where expected.
  • Fast name/address entry continues to batch into a single draft-order update.

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bc32f15

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@godaddy/react Patch
nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant