Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OfflineExchange optimistic updates retaining values #3663

Open
3 tasks done
danholladayrexel opened this issue Sep 5, 2024 · 0 comments
Open
3 tasks done

OfflineExchange optimistic updates retaining values #3663

danholladayrexel opened this issue Sep 5, 2024 · 0 comments

Comments

@danholladayrexel
Copy link

Describe the bug

Note: trey-rexel mentioned this issue in Discord, with a different repository and steps.

We are experiencing an issue with the offlineExchange in URQL where optimistic updates appear to retain values from a cache.readQuery after the first call. The second call with the same input results in the UI rolling back to the value from the first call, even if other changes have happened. This behavior results in the UI becoming erratic and often displaying incorrect data.

This is not related to when the device comes online. The behavior described is while entirely offline.

To reproduce using the linked repository:

  1. While online and from the index page: add one of each product to a cart.
  2. View the cart page and note the Product Quantity of each product appears correct, all of them at 1.
  3. Use devtools to go offline and go back to the index page.
  4. Add one of each of the items to the same cart.
  5. View the cart page, again, and note the Product Quantities still appear correct, all of them at 2.
  6. Return to the index page and add each of the items to the cart for a third time.
  7. View the cart page and notice Product Quantities will revert back to values that happened in a previous step. They should have all been 3, but instead only the last mutation called will have 3, the others will have 2.

If you keep adding items, or clear the cart and re-add a single item, it becomes a guessing game as to what will display.

Reproduction

https://github.com/danholladayrexel/urql-offline-issue

Urql version

@urql/vue: 1.4.1

Validations

  • I can confirm that this is a bug report, and not a feature request, RFC, question, or discussion, for which GitHub Discussions should be used
  • Read the docs.
  • Follow our Code of Conduct
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

No branches or pull requests

1 participant