Skip to content

[4.x] Auto retry requests where the cart has expired#1236

Open
Jade-GG wants to merge 2 commits into4.xfrom
feature/auto-retry
Open

[4.x] Auto retry requests where the cart has expired#1236
Jade-GG wants to merge 2 commits into4.xfrom
feature/auto-retry

Conversation

@Jade-GG
Copy link
Copy Markdown
Collaborator

@Jade-GG Jade-GG commented Mar 18, 2026

ref: RAP-1854, BORDEX-1358

Currently, when your cart expires you will sometimes get an ugly and scary error telling you your cart ID is not valid.

With this PR, I check for this error and underwater we retry the request once, adding a more friendly notification telling you that your cart has expired in the meantime. This means that, for example, if you add a product to your expired cart, it will make a new cart and then re-add the product to this new cart.

This makes the user experience for expired carts a bit nicer.


return await window.magentoGraphQL(
query,
{ ...variables, cartId: mask.value, cart_id: mask.value },
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately some requests have cartId and others have cart_id. This was the simplest and most readable way to catch both.

Copy link
Copy Markdown
Member

@indykoning indykoning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code wise it's looking good.
But perhaps we can simplify it a lot by doing what we are doing in the useUser store:

window.setTimeout(() => refresh(), 200)

I reckon refreshing the cart after loading the page will tackle most of the problems users experience.

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