pwa-studio icon indicating copy to clipboard operation
pwa-studio copied to clipboard

[bug]: Stale cartId after guest user logs in

Open joseamietta opened this issue 5 months ago • 4 comments

Describe the bug

When a user browses the site as a guest and then logs in, several GraphQL calls are executed with a stale or old cartId, which leads to errors in the Magento logs.

To reproduce

Steps to reproduce the behavior:

  1. Open the website in a guest session (not logged in).
  2. Log in with a registered user account.
  3. Check the next GraphQl in the browser inspector: getItemCount, MiniCartQuery
  4. See the error: The current user cannot perform operations on cart ...

Expected behavior

Merge the guest's cart with the customer's cart and correctly replace the guest's cartId with the new customer's cartId for all subsequent GraphQL calls. And avoid dispatch request with a stale cartId.

Screenshots

https://github.com/user-attachments/assets/1a03c3db-7362-4da6-9903-6ea3472cc99d

Image

Possible solutions

Checking the talon useSignIn.js I can see that setToken is called before clear cart and customer data. If setToken is moved after deleting that data the errors is not thrown.

Please complete the following device information:

  • Device [Notebook]:
  • Browser [Chrome]:
  • Browser Version [Version 138.0.7204.100 (Official Build) (64-bit)]:
  • Magento Version [Adobe Commerce 2.4.7-p6]:

Please let us know what packages this bug is in regards to:

  • [ ] venia-concept
  • [x] venia-ui
  • [ ] pwa-buildpack
  • [x] peregrine
  • [ ] pwa-devdocs
  • [ ] upward-js
  • [ ] upward-spec
  • [ ] create-pwa

joseamietta avatar Aug 14 '25 12:08 joseamietta

Hi @joseamietta. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information. Add a comment to assign the issue: @magento I am working on this


Join Magento Community Engineering Slack and ask your questions in #github channel.

m2-assistant[bot] avatar Aug 14 '25 12:08 m2-assistant[bot]

@magento I am working on this

joseamietta avatar Aug 14 '25 12:08 joseamietta

@adobe export issue to Jira project PWA

glo82145 avatar Dec 02 '25 11:12 glo82145

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/PWA-3631 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Dec 02 '25 11:12 github-jira-sync-bot