commerce icon indicating copy to clipboard operation
commerce copied to clipboard

TAGS.cart Not Revalidating Correctly After Page Refresh

Open oscarmylla opened this issue 1 year ago • 3 comments

After performing a page refresh, TAGS.cart is not revalidated correctly. This leads to potential inconsistencies between the client-side and server-side state of the cart data.

https://github.com/user-attachments/assets/c4dbb3fd-9400-43b5-81f2-96081183f1f6

oscarmylla avatar Nov 06 '24 19:11 oscarmylla

It appears that the issue arises from using getCart within the updateItemQuantity action, which then revalidates the tag that getCart utilizes within the same action.

When applying "no-store" to all getCart invocations within the cart actions, everything functions as expected.

Do you have any suggestions for a more optimal solution?

oscarmylla avatar Nov 06 '24 20:11 oscarmylla

@oscarmylla. Ha! Literally just finished a recording of this exact bug, but thankfully spotted your issue before opening a dupe. I can confirm "no-store" on getCart serves as a workaround. Subscribing to hopefully see the more optimal solution that gets implemented.

dsbrianwebster avatar Nov 24 '24 03:11 dsbrianwebster

I was thinking. When we try revalidate the tag TAGS.cart thats mean, all the cart cached will revalidate no? no matter the user. Why not ${TAGS.cart}-${cartId}

nikosantis avatar Dec 11 '24 13:12 nikosantis