Skip to content

Sharing patch we use to fix stale cache/query bugs #5938

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

Closed
tgriesser opened this issue Feb 11, 2020 · 2 comments
Closed

Sharing patch we use to fix stale cache/query bugs #5938

tgriesser opened this issue Feb 11, 2020 · 2 comments
Assignees
Milestone

Comments

@tgriesser
Copy link
Contributor

Intended outcome:

I believe this is related to:
#3633, #5781, #5790

apollographql/react-apollo#3774
apollographql/react-apollo#3361

Actual outcome:

This is the patch-package we're using at Cypress to fix this:

diff --git a/node_modules/@apollo/client/apollo-client.cjs.js b/node_modules/@apollo/client/apollo-client.cjs.js
index 91ed213..8426975 100644
--- a/node_modules/@apollo/client/apollo-client.cjs.js
+++ b/node_modules/@apollo/client/apollo-client.cjs.js
@@ -931,6 +931,8 @@ var ObservableQuery = (function (_super) {
                     else {
                         iterateObserversSafely(_this.observers, 'next', result);
                     }
+                } else {
+                    iterateObserversSafely(_this.observers, 'next', result);
                 }
             },
             error: onError,
diff --git a/node_modules/@apollo/client/core/ObservableQuery.js b/node_modules/@apollo/client/core/ObservableQuery.js
index fe1b844..4898eab 100644
--- a/node_modules/@apollo/client/core/ObservableQuery.js
+++ b/node_modules/@apollo/client/core/ObservableQuery.js
@@ -333,6 +333,8 @@ var ObservableQuery = (function (_super) {
                     else {
                         iterateObserversSafely(_this.observers, 'next', result);
                     }
+                } else {
+                    iterateObserversSafely(_this.observers, 'next', result);
                 }
             },
             error: onError,

I don't know if this is necessarily the "correct" place to fix the issue, because it ends up triggering the observable more often than you'd normally want. But it does the trick and fixes this stale data for us, which IIRC was due to a super hard to track down and reproduce non-deterministic race-condition around deep equality in the in-memory store - we only were able to eventually reproduce and fix because of how fast the test suite runs.

Mostly just sharing to see if others can try it out and see if it helps with their issues, which might in-turn help the Apollo devs narrow down and fix the source of the underlying issue.

How to reproduce the issue:

See other issues.

Versions

3.0

@benjamn
Copy link
Member

benjamn commented Feb 24, 2020

Thanks @tgriesser! I remember you mentioning something about this at Summit. We will make sure to address this issue the right way (whatever that turns out to be) before the AC3 release.

@hwillson hwillson modified the milestones: Release 3.0, Post 3.0 Jul 10, 2020
@hwillson
Copy link
Member

A lot of the Apollo Client internals have changed since v3 was launched. We recommend trying a more modern version of @apollo/client. Let us know if you're still encountering this issue. Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants