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

Revert "Avoid network after incomplete optimistic cache results. (#6419)" #6493

Merged
merged 1 commit into from
Jun 25, 2020

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Jun 25, 2020

This reverts commit 9450938 (#6419).

The logic of diff.optimistic needs rethinking. Any query could read from the cache at a time when optimistic updates are in progress, and that possibility should not affect the network behavior of the query.

I had hoped that the dependency tracking system would serve to protect queries whose field dependencies were unrelated to the optimistic updates, but I have now observed at least one case where this hope was badly mistaken, while debugging an endless loading spinner issue with the latest versions of @apollo/client (rc.3-rc.8) in the studio.apollographql.com application.

As I mentioned in #6419, I was not able to reproduce the original scenario using an ordinary optimistic mutation, so I think we should wait until someone can provide a more realistic reproduction of the problem.

I have left the test in place, disabled with itAsync.skip, so that we can revisit this functionality in the future.

…)"

This reverts commit 9450938.

The logic of diff.optimistic needs rethinking. Any query could read from
the cache at a time when optimistic updates are in progress, and that
possibility should not affect the network behavior of the query.

I had hoped that the dependency tracking system would serve to protect
queries whose field dependencies were unrelated to the optimistic updates,
but I have now observed at least one case where this hope was badly
mistaken, while debugging an endless loading spinner issue with the latest
versions of @apollo/client (rc3-rc.8) in the studio.apollographql.com
application.

As I mentioned in #6419, I was not able to reproduce the original scenario
using an ordinary optimistic mutation, so I think we should wait until
someone can provide a more realistic reproduction of the problem:
#6419 (comment)

I have left the test in place, disabled with itAsync.skip, so that we can
revisit this functionality in the future.
Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

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

Argh! Thanks for reverting @benjamn.

@benjamn benjamn merged commit 0530ee0 into master Jun 25, 2020
@benjamn benjamn deleted the revert-pr-6419 branch June 25, 2020 15:32
@darkbasic
Copy link

@benjamn what do you mean with "ordinary" optimistic mutation? What doesn't qualify https://github.com/darkbasic/gh6183/blob/master/packages/client/src/Articles.tsx#L23 as "ordinary"?

benjamn added a commit that referenced this pull request Aug 17, 2020
I first attempted to solve this bug in #6419, but that approach was
flawed, and we ultimately reverted it in #6493. Both of these changes
happened shortly before the AC3 launch (rc.3 and rc.9, respectively).

The key to this solution is that diff.fromOptimisticTransaction is only
ever set by the InMemoryCache broadcast code, when we know that we've just
performed an optimistic transaction, and we're broadcasting to a query
watcher that requested optimistic data. The QueryInfo class receives this
broadcast, and uses diff.fromOptimisticTransaction to decide whether to do
a full reapplication of the chosen fetch policy by calling oq.reobserve(),
or simply to deliver a single cache result by calling oq.observe().
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants