Skip to content

fix: prevent unhandled errors from superseded cart mutations - #3998

Open
fredericoo wants to merge 2 commits into
previewfrom
fb-swallow-cart-abort-errors
Open

fix: prevent unhandled errors from superseded cart mutations#3998
fredericoo wants to merge 2 commits into
previewfrom
fb-swallow-cart-abort-errors

Conversation

@fredericoo

Copy link
Copy Markdown
Contributor

TL;DR: Rapid cart updates deliberately abort superseded requests, but the correlated Standard Event promise was left unobserved and surfaced those cancellations as console errors.

Before

Repeatedly updating the same cart line produced an unhandled AbortError for every superseded request, even though the cart handled the cancellation correctly.

After

Hydrogen observes the redundant correlated event promise while keeping the caller-facing action promise authoritative. Expected cancellations stay silent; genuine mutation failures still follow the existing error path.

What this changes

  • Observes the deduplicated Standard Event promise before discarding it.
  • Adds regression coverage for asynchronous correlated events cancelled by a newer cart mutation.

Developer impact

Includes a patch changeset for @shopify/hydrogen. There are no public API or runtime contract changes.

Out of scope

  • Server-side cart conflict responses remain genuine failures and are not swallowed.

Risk

  • Low. The change only handles a redundant promise after its event has already been correlated with the authoritative action promise.

How to Test

  1. Run pnpm --filter @shopify/hydrogen build.
  2. Run pnpm --filter @shopify/hydrogen-template-react-router dev.
  3. Open http://localhost:5173, add a product, and open the cart drawer.
  4. Click the line item's increase button repeatedly in quick succession.
  5. Confirm the cart settles on the latest quantity without unhandled AbortError messages in the browser console.

@fredericoo fredericoo changed the title Fix unhandled errors from superseded cart mutations fix: prevent unhandled errors from superseded cart mutations Sep 8, 2026
@fredericoo
fredericoo marked this pull request as ready for review September 8, 2026 12:52
@fredericoo
fredericoo requested a review from a team as a code owner September 8, 2026 12:52
@fredericoo fredericoo self-assigned this Sep 8, 2026
@fredericoo fredericoo added the gsd:50917 New Hydrogen label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants